-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
37 lines (28 loc) · 1.08 KB
/
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
import os
def list_config():
resource_dir = os.path.join(os.path.dirname(__file__), "resource")
config_names = []
for config in os.listdir(resource_dir):
if config.startswith("config"):
config_name = config.split(".")[1]
config_names.append(config_name)
return config_names
def current():
resource_dir = os.path.join(os.path.dirname(__file__), "resource")
cm_path = os.path.join(resource_dir, "cm.txt")
with open(cm_path, 'r') as f:
return f.read()
def remove_current():
resource_dir = os.path.join(os.path.dirname(__file__), "resource")
cm_path = os.path.join(resource_dir, "cm.txt")
with open(cm_path, 'w') as f:
f.write('')
def remove_config(name):
resource_dir = os.path.join(os.path.dirname(__file__), "resource")
config_path = os.path.join(resource_dir, 'config.%s' % name)
os.remove(config_path)
def update_cm(name):
resource_dir = os.path.join(os.path.dirname(__file__), "resource")
cm_path = os.path.join(resource_dir, "cm.txt")
with open(cm_path, 'w') as f:
f.write(name)