-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcomplete_keys.py
43 lines (36 loc) · 1006 Bytes
/
complete_keys.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
#!/usr/bin/python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
from __future__ import print_function, unicode_literals, absolute_import
import sys
from workflow import Workflow, web, ICON_WARNING
import json
USER_AGENT = 'Alfred-JQ/{version} ({url})'
def main(wf):
queries = wf.args
q = queries[0].strip()
error_code = queries[-1]
if error_code != '0':
wf.add_item('Invalid JSON String in clipboard.',
valid=False,
icon='error.png')
wf.send_feedback()
return 0
keys = queries[1:-1]
url = None
for k in keys:
if q[-1] != '.':
full_q = q + '.' + k
else:
full_q = q + k
wf.add_item(k,
arg=full_q,
autocomplete=full_q,
valid=True,
icon='icon.png')
wf.send_feedback()
return 0
if __name__ == '__main__':
wf = Workflow()
log = wf.logger
sys.exit(wf.run(main))