-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig_utils.py
178 lines (141 loc) · 4.86 KB
/
config_utils.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import yaml
class ConfigUtils:
def __init__(self):
self.config_file = 'config.yml'
with open(self.config_file, 'r') as file:
self.config = yaml.safe_load(file)
def save_config(self):
with open(self.config_file, 'w') as file:
yaml.dump(self.config, file)
def get_recent_projects(self):
if self.config:
return self.config['recent-projects']
def set_recent_projects(self, projects):
if self.config:
self.config['recent-projects'] = projects
self.save_config()
def get_phases(self):
if self.config:
return self.config['phases']
def set_screen_size(self, height, width):
if self.config:
self.config['window-size'] = [height, width]
self.save_config()
def get_screen_size(self):
if self.config:
return self.config['window-size']
def get_data_folders(self):
if self.config:
return self.config['data-folders']
def get_patient_concerns(self):
if self.config:
return self.config['patient-concerns']
def get_first_time(self):
if self.config:
if self.config['first-time']:
self.config['first-time'] = False
self.save_config()
return True
else:
return False
def get_logs_dir(self):
if self.config:
if self.config['logs-dir']:
return self.config['logs-dir']
def set_logs_dir(self, new_logs_dir):
if self.config:
if self.config['logs-dir']:
self.config['logs-dir'] = new_logs_dir
self.save_config()
return True
else:
return False
def get_fps(self):
if self.config:
if self.config['fps']:
return float(self.config['fps'])
def set_fps(self, new_fps):
if self.config:
if self.config['fps']:
self.config['fps'] = new_fps
self.save_config()
return True
else:
return False
def get_cwd(self):
if self.config:
return str(self.config['cwd'])
def set_cwd(self, cwd):
if self.config:
self.config['cwd'] = cwd
self.save_config()
def get_e4(self):
if self.config:
return bool(self.config['enable-e4'])
def set_e4(self, set_e4):
if self.config:
self.config['enable-e4'] = set_e4
self.save_config()
def get_woodway(self):
if self.config:
return bool(self.config['enable-woodway'])
def set_woodway(self, set_woodway):
if self.config:
self.config['enable-woodway'] = set_woodway
self.save_config()
def get_ble(self):
if self.config:
return bool(self.config['enable-ble'])
def set_ble(self, set_ble):
if self.config:
self.config['enable-ble'] = set_ble
self.save_config()
def get_review(self):
if self.config:
return bool(self.config['enable-review'])
def set_review(self, set_review):
if self.config:
self.config['enable-review'] = set_review
self.save_config()
def get_clickmode(self):
if self.config:
return bool(self.config['enable-singleclick'])
def set_clickmode(self, set_clickmode):
if self.config:
self.config['enable-singleclick'] = set_clickmode
self.save_config()
def get_woodway_a(self):
if self.config:
return str(self.config['woodway-a-sn'])
def set_woodway_a(self, woodway_sn):
if self.config:
self.config['woodway-a-sn'] = woodway_sn
self.save_config()
def get_woodway_b(self):
if self.config:
return str(self.config['woodway-b-sn'])
def set_woodway_b(self, woodway_sn):
if self.config:
self.config['woodway-b-sn'] = woodway_sn
self.save_config()
def get_auto_export(self):
if self.config:
return bool(self.config['auto-export'])
def set_auto_export(self, export_option):
if self.config:
self.config['auto-export'] = export_option
self.save_config()
def get_use_count(self):
if self.config:
return int(self.config['use-count'])
def increment_use_count(self):
if self.config:
self.config['use-count'] = int(self.config['use-count']) + 1
self.save_config()
def get_protocol_beep(self):
if self.config:
return bool(self.config['protocol-beep'])
def set_protocol_beep(self, new_value):
if self.config:
self.config['protocol-beep'] = bool(new_value)
self.save_config()