Added collab
This commit is contained in:
@@ -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
45
modules/config/pusher.py
Normal 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
|
||||
Reference in New Issue
Block a user