-
Notifications
You must be signed in to change notification settings - Fork 0
/
editor.py
36 lines (26 loc) · 844 Bytes
/
editor.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
import urwid
import sys
import json
from domain.errors import ConfigError
from interface.screen import Screen
def prepare_config_file():
if len(sys.argv) < 2:
raise ConfigError('Provide config file name as the first parameter.')
config_file_name = './config/' + str(sys.argv[1]).rstrip('.json') + '.json'
config_file = open(config_file_name, 'r')
contents = config_file.read()
configuration = json.loads(contents)
if not configuration:
raise ConfigError('File not found')
return configuration
def main_loop():
configuration = prepare_config_file()
main_screen = Screen(configuration)
loop = urwid.MainLoop(main_screen, (), handle_mouse=False)
loop.run()
if __name__ == '__main__':
try:
main_loop()
except Exception as e:
print(str(e))
exit()