From 421fc9b98af1f5a71b6f880d77cf879b85e90394 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Sun, 27 Mar 2022 19:23:42 +0200 Subject: [PATCH] Reorganize files to convert to python package --- main.py => its_matrix_bot/__init__.py | 17 ++--------------- its_matrix_bot/__main__.py | 14 ++++++++++++++ config.py => its_matrix_bot/config.py | 0 its_api.py => its_matrix_bot/its_api.py | 2 +- 4 files changed, 17 insertions(+), 16 deletions(-) rename main.py => its_matrix_bot/__init__.py (87%) mode change 100644 => 100755 create mode 100644 its_matrix_bot/__main__.py rename config.py => its_matrix_bot/config.py (100%) rename its_api.py => its_matrix_bot/its_api.py (96%) diff --git a/main.py b/its_matrix_bot/__init__.py old mode 100644 new mode 100755 similarity index 87% rename from main.py rename to its_matrix_bot/__init__.py index 94ebc98..856344d --- a/main.py +++ b/its_matrix_bot/__init__.py @@ -1,11 +1,10 @@ -import argparse import datetime from nio.rooms import MatrixRoom from nio.events.room_events import RoomMessage import simplematrixbotlib as botlib -from its_api import ItSyndikatApi -from config import Config +from .its_api import ItSyndikatApi +from .config import Config class ItSyndikatBot: @@ -77,15 +76,3 @@ class ItSyndikatBot: async def spaceping(self, room: MatrixRoom, message: RoomMessage): await self.its_api.ping() await self.reply(room, message, "Hello Space!") - - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="IT-Syndikat matrix bot") - parser.add_argument( - "-c", "--config", - help="path to the config file", - ) - - args = parser.parse_args() - - ItSyndikatBot(Config(args.config)) diff --git a/its_matrix_bot/__main__.py b/its_matrix_bot/__main__.py new file mode 100644 index 0000000..ac00437 --- /dev/null +++ b/its_matrix_bot/__main__.py @@ -0,0 +1,14 @@ +import argparse + +from . import ItSyndikatBot +from .config import Config + +parser = argparse.ArgumentParser(description="IT-Syndikat matrix bot") +parser.add_argument( + "-c", "--config", + help="path to the config file", +) + +args = parser.parse_args() + +ItSyndikatBot(Config(args.config)) diff --git a/config.py b/its_matrix_bot/config.py similarity index 100% rename from config.py rename to its_matrix_bot/config.py diff --git a/its_api.py b/its_matrix_bot/its_api.py similarity index 96% rename from its_api.py rename to its_matrix_bot/its_api.py index 72fa8e9..9186cf1 100644 --- a/its_api.py +++ b/its_matrix_bot/its_api.py @@ -1,6 +1,6 @@ import aiohttp -from config import Config +from .config import Config class ItSyndikatApi: base_url: str