-
Notifications
You must be signed in to change notification settings - Fork 9
/
write.py
42 lines (36 loc) · 958 Bytes
/
write.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
# -*- coding:utf-8 -*-
import json,sys
from workflow.workflow3 import Workflow
def main(wf):
args = wf.args
data = args[0]
op = args[1]
if op == 'add':
f = open('config.json', 'r')
j_config = json.load(f)
f.close()
f = open('config.json', 'w+')
j_config['units'].append(data)
json.dump(j_config,f)
f.close()
wf.item_class.arg = data
if op == 'del':
f = open('config.json', 'r')
j_config = json.load(f)
f.close()
f = open('config.json', 'w+')
j_config['units'].remove(data)
json.dump(j_config, f)
f.close()
if op == 'base':
f = open('config.json', 'r+')
j_config = json.load(f)
j_config['base'] = data
f.seek(0)
json.dump(j_config, f)
f.close()
wf.send_feedback()
if __name__ == '__main__':
wf = Workflow()
log = wf.logger
sys.exit(wf.run(main))