-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_reader.py
53 lines (45 loc) · 1.37 KB
/
config_reader.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os
import tempfile
import json
from types import SimpleNamespace
import yaml
currpath = os.path.dirname(os.path.realpath(__file__))
with open(os.path.join(currpath, 'config.yaml')) as f:
_config = yaml.safe_load(f)
with open(os.path.join(currpath, 'config_theme.yaml')) as f:
_theme = yaml.safe_load(f)
with open(os.path.join(currpath, 'config_waterfall_server.yaml')) as f:
_waterfall_server = yaml.safe_load(f)
theme = tempfile.NamedTemporaryFile(mode='w')
json.dump(_theme, theme)
theme.flush()
system_display = {
"top_bar_size": 64,
"top_bar_app_label_width": 192,
"target_fps": 60
}
system_display.update(_config['system']['display'])
system_switcher = {
"buttons_x": 4,
"button_h": 64,
"button_margin": 2
}
system_switcher.update(_config['system'].get('switcher', {}))
class cfg:
waterfall_server = SimpleNamespace(
**_waterfall_server.get('waterfall_server', {})
)
display = SimpleNamespace(
**system_display,
size=(system_display.get('display_w'), system_display.get('display_h'))
)
switcher = SimpleNamespace(**system_switcher)
modules = {}
for m in _config['modules'].values():
modules[m['display_name']] = SimpleNamespace(
type=m['type'],
display_name=m['display_name'],
config=m['config']
)
theme_file = theme.name
theme = _theme