Skip to content

Commit

Permalink
build: Move subscriptions to Docker volume.
Browse files Browse the repository at this point in the history
  • Loading branch information
BURG3R5 committed Nov 18, 2022
1 parent 97b204c commit 3c9526d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
.venv
venv

# Storage
data

# Temporary files
.data
logs
__pycache__/
*.pyc
12 changes: 6 additions & 6 deletions bot/utils/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]] = {
Expand Down

0 comments on commit 3c9526d

Please sign in to comment.