-
Notifications
You must be signed in to change notification settings - Fork 9
/
add.py
42 lines (32 loc) · 935 Bytes
/
add.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
subtitle = 'Add new currency to panel'
"""
push item into item class
"""
def push_item(item_title,item_subtitle,flag,value):
wf.add_item(title=item_title,
subtitle=item_subtitle,
icon='flags/{0}.png'.format(flag),
valid='yes',
arg=str(value)+" add")
def main(wf):
args = wf.args
args = [x.upper() for x in args]
length = len(args)
f = open('currencies.json', 'r')
j_currencies = json.load(f)
if length == 0:
for e in j_currencies:
push_item(e, subtitle, e, e)
if length == 1:
for key in j_currencies:
if key.startswith(args[0]):
push_item(key, subtitle, key, key)
wf.send_feedback()
if __name__ == '__main__':
wf = Workflow()
log = wf.logger
sys.exit(wf.run(main))
#main([])