-
Notifications
You must be signed in to change notification settings - Fork 4
/
set-city.py
36 lines (26 loc) · 837 Bytes
/
set-city.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
# coding=utf-8
import sys
import csv
import json
from ualfred import Workflow3, notify
log = None
def main(wf):
# Get args from Workflow, already in normalized Unicode
args = wf.args
with open('cityidloc.csv', newline='', encoding='utf-8') as csvfile:
csv_reader = csv.reader(csvfile, delimiter=',')
for rows in csv_reader:
if args[0] in rows[1]:
log.debug(rows)
wf.add_item(rows[1], arg=json.dumps(rows), uid=csv_reader.line_num, valid=True)
wf.store_data(u'cy-city', args[0])
# Add an item to Alfred feedback
wf.send_feedback()
if __name__ == '__main__':
# Create a global `Workflow` object
wf = Workflow3()
# Call your entry function via `Workflow.run()` to enable its helper
# functions, like exception catching, ARGV normalization, magic
# arguments etc.
log = wf.logger
sys.exit(wf.run(main))