-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconfigurator.py
More file actions
38 lines (28 loc) · 815 Bytes
/
configurator.py
File metadata and controls
38 lines (28 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import json
import logging
from os.path import isfile
logger = logging.getLogger("main")
def initialize():
if not isfile("settings.json"):
save("settings.json", default())
def save(cfg_file, settings):
settings = json.dumps(settings, indent=4)
logger.info(f"Saving settings to {cfg_file}")
with open(cfg_file, "w") as f:
f.write(settings)
def load(cfg_file):
logger.info(f"Loading {cfg_file}")
settings = {}
with open(cfg_file) as f:
settings = json.load(f)
return settings
def default():
return {
"default_msg": "",
"default_name": "Anon",
"pb_token": "",
"sl_token": "",
"redirect_uri": "http://localhost:1337",
"redirect_uri_short": "localhost",
"port": 1337
}