-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.py
35 lines (30 loc) · 948 Bytes
/
config.py
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
from medium import BluRay, UHDBluRay
import json
from typing import Union
import os
class Config:
def __init__(self):
if os.path.exists('./config.json'):
self.fromjson()
else:
self.medium = BluRay()
self.ui = {
'TrackSort': {'MaxRow': 16},
'Asset': {'MaxRow': 20},
'Table': {'CellWidth': 63,
'Width': 560,
'Height': 170}
}
def fromjson(self):
with open('./config.json') as f:
conf = json.load(f)
self.medium:Union[BluRay, UHDBluRay] = conf['medium'] == 'BluRay' and BluRay() or UHDBluRay()
self.ui = conf['ui']
def tojson(self):
conf = {
'medium': self.medium.type_,
'ui': self.ui
}
with open('./config.json', 'w') as f:
json.dump(conf, f, indent=4)
P = Config()