-
Notifications
You must be signed in to change notification settings - Fork 0
/
getclips.py
90 lines (66 loc) · 2.84 KB
/
getclips.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/python
# encoding: utf-8
from __future__ import unicode_literals
import os
import sys
from workflow import Workflow3
wf = None
log = None
nothing_found_error_text = 'Nothing found'
def main(wf):
clipFolders = ["~/Dropbox/Library/Application Support/Script Debugger 7/Clippings", "/Applications/Script Debugger.app/Contents/ApplicationSupport/Clippings"]
log.debug(os.getenv('thePath'))
try:
thePath = os.getenv('thePath')
except Exception:
thePath = None
pass
if thePath is None:
theFolder = clipFolders
else:
theFolder = [thePath]
x = 0
while x < len(theFolder):
thePath = None
files = os.listdir(os.path.expanduser(theFolder[x]))
for file in files:
if ".DS" not in file:
if ".txt" not in file:
if thePath is None:
_arg = theFolder[x] + "/" + file
else:
_arg = thePath + "/" + file
itm = wf.add_item(title=file,
subtitle="view clippings for " + file,
arg= _arg,
autocomplete=file,
valid=True,
icon=theFolder[x] + "/" + file,
icontype="fileicon",
quicklookurl=file)
itm.setvar('isLeaf', 'false')
itm.setvar('thePath', theFolder[x] + "/" + file)
itm.add_modifier('cmd', subtitle="open the " + file + " folder in Finder", arg=theFolder[x] + "/" + file, valid=True)
itm.add_modifier('alt', subtitle="open clippings folder", arg=theFolder[0], valid=True)
else:
_arg = file
if thePath is None:
thePath = os.path.expanduser(theFolder[x])
itm = wf.add_item(title=file,
subtitle="insert clipping",
arg=_arg,
autocomplete=file,
valid=True,
icon=file,
icontype="fileicon",
quicklookurl=file)
itm.setvar('isLeaf', 'true')
itm.setvar('thePath', thePath + "/" + file)
itm.add_modifier('cmd', subtitle="edit clipping in default text editor", arg=thePath + "/" + file, valid=True)
itm.add_modifier('alt', subtitle="open clippings folder", arg=theFolder[0], valid=True)
x += 1
return wf.send_feedback()
if __name__ == "__main__":
wf = Workflow3()
log = wf.logger
sys.exit(wf.run(main))