-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsearch_tasks.py
executable file
·51 lines (47 loc) · 1.5 KB
/
search_tasks.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
#!/usr/bin/env python3
# encoding: utf-8
from Alfred import Items, Tools
from Notes import Search
items = Items()
query = Tools.getArgv(1)
search = Search()
tasks = search.tasks(query)
if len(tasks) > 0:
for file in tasks:
file_title = file['title'] if file['title'] != str() else search.getNoteFilename(file['path'])
items.setItem(
arg=file['path'],
subtitle="\u2192 {0} (\u2318 Open in The Archive, \u2325 Open in Default Editor)".format(file['filename']),
title=file['todo'],
type='file',
valid=True,
variables={
"todo": file['todo'],
"todo_query": query,
"todo_status": file['status'],
},
)
items.addMod(
arg=file['path'],
icon_path="icons/the-archive.png",
icon_type="image",
key="cmd",
subtitle="Open \"{0}\" in The Archive".format(file['filename']),
)
items.addMod(
arg=file['path'],
icon_path="icons/editor.png",
icon_type="image",
key="alt",
subtitle="Open \"{0}\" in the default editor".format(file['filename']),
)
items.setIcon('icons/todo.png' if file['status'] == 'pending' else 'icons/done.png', 'image')
items.addItem()
else:
items.setItem(
title="No tasks found!",
subtitle="No task matches the search term",
valid=False,
)
items.addItem()
items.write()