Added collab

This commit is contained in:
BarsTiger
2022-12-27 14:18:22 +02:00
parent 4507814fcd
commit b29a172bf8
17 changed files with 1150 additions and 34 deletions

View File

@@ -22,3 +22,12 @@ class PathsModel:
first_browser_path: str
second_browser_path: str
collections_list: List[str]
@dataclass_json
@dataclass(frozen=True)
class PusherModel:
app_id: str
key: str
secret: str
cluster: str

45
modules/config/pusher.py Normal file
View File

@@ -0,0 +1,45 @@
from modules.config.model import PusherModel
import json
import os
class PusherConfig:
@staticmethod
def default():
return {
"app_id": str(),
"key": str(),
"secret": str(),
"cluster": str()
}
@staticmethod
def fix() -> None:
try:
with open("data/config.pusher", "w") as file:
json.dump(PusherConfig.default(), file)
except FileNotFoundError:
if not os.path.exists('data'):
os.mkdir('data')
PusherConfig.fix()
@staticmethod
def get() -> PusherModel:
try:
with open("data/config.pusher", "r") as file:
return PusherModel.from_dict(json.load(file))
except:
PusherConfig.fix()
return PusherConfig.get()
@staticmethod
def update(key: str, value: str | list | None) -> dict:
with open("data/config.pusher", "r") as file:
settings = json.load(file)
settings[key] = value
with open("data/config.pusher", "w") as file:
json.dump(settings, file)
return settings