-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.py
46 lines (42 loc) · 1.48 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
import os
import json
def get_drink_config():
drink_config = {}
if os.path.exists("config.json"):
with open('config.json', 'r') as f:
config_len = len(f.readlines())
with open('config.json', 'r') as f:
if config_len != 0:
drink_config = json.load(f)
if len(drink_config) == 0:
drink_config = {
"active_time_list": [
{
"active": False,
"start_time": "00:00",
"end_time": "00:00"
},
{
"active": False,
"start_time": "00:00",
"end_time": "00:00"
},
{
"active": False,
"start_time": "00:00",
"end_time": "00:00"
},
],
"remind_interval": 0, # 间隔时间(分钟)
"drinking_count": 8, # 喝水数量
"view_message": "positive", # 窗口信息 正着计数(positive)/倒着计数(negative)
"view_top": "normal" # 窗口 置顶(top)/正常(normal)/置底(under)
}
with open('config.json', 'w') as f:
json.dump(drink_config, f)
return drink_config
def set_drink_config(new_drink_config):
drink_config = new_drink_config
with open('config.json', 'w') as f:
json.dump(drink_config, f)
return drink_config