diff --git a/.gitignore b/.gitignore index e4057d7..faec48c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,8 +9,9 @@ .venv venv +# Storage +data + # Temporary files -.data -logs __pycache__/ *.pyc diff --git a/bot/utils/storage.py b/bot/utils/storage.py index 77b0946..8e29145 100644 --- a/bot/utils/storage.py +++ b/bot/utils/storage.py @@ -17,10 +17,10 @@ class Storage: @staticmethod def export_subscriptions(subscriptions: dict[str, set[Channel]]): """ - Saves the passed subscriptions map to the file ".data". + Saves the passed subscriptions map in "data/subscriptions". :param subscriptions: Map containing the current subscriptions. """ - with open(".data", mode="w", encoding="utf-8") as file: + with open("data/subscriptions", mode="w", encoding="utf-8") as file: exportable_dict: dict[str, dict[str, list[str]]] = { repo: { channel.name: [event.keyword for event in channel.events] @@ -34,12 +34,12 @@ def export_subscriptions(subscriptions: dict[str, set[Channel]]): @staticmethod def import_subscriptions() -> dict[str, set[Channel]]: """ - Loads subscriptions from the file ".data", if it exists. - If there is no ".data" file, returns default subscriptions for testing and dev. + Loads subscriptions from "data/subscriptions", if it exists. + If the file doesn't exist, returns default subscriptions for testing and dev. :return: Map containing the saved subscriptions. """ - if os.path.exists(".data"): - with open(".data", encoding="utf-8") as file: + if os.path.exists("data/subscriptions"): + with open("data/subscriptions", encoding="utf-8") as file: imported_dict: dict[str, dict[str, list[str]]] = json.load(file) subscriptions: dict[str, set[Channel]] = {