-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakeThings.py
More file actions
93 lines (71 loc) · 2.38 KB
/
makeThings.py
File metadata and controls
93 lines (71 loc) · 2.38 KB
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
91
import subprocess
import logging
def make_new_task(title: str = ...,
completed: bool = False,
cancelled: bool = False,
show_quick_entry: bool = False,
reveal: bool = False,
notes: str = ...,
checklist_items: list = ...,
when: str = ...,
deadline: str = ...,
tags: list = ...,
list: str = ...,
heading: str = ...,
creation_date: str = ...,
completion_date: str = ...) -> None:
arguments = locals()
if show_quick_entry:
arguments.pop('show_quick_entry')
arguments['show-quick-entry'] = True
if checklist_items != Ellipsis:
checklist = arguments.pop('checklist_items')
arguments['checklist-items'] = '\n'.join(checklist)
if tags != Ellipsis:
arguments['tags'] = ','.join(tags)
parameters = [f"{k}={v}" for k, v in arguments.items() if v != Ellipsis]
params = '&'.join(parameters)
base_url = "things:///add?reveal=False&"
subprocess.run(['open', f"{base_url + params}"])
heading: str = "NEW TASK CREATED BY MAKETHINGS"
logging.info(f"\n{heading:-^54}\nTitle: {title}")
def update_task(auth_token: str,
task_id: str,
title: str = ...,
completed: bool = False,
cancelled: bool = False,
reveal: bool = False,
show: bool = False,
duplicate: bool = ...,
prepend_notes: str = ...,
append_notes: str = ...,
checklist_items: list = ...,
when: str = ...,
deadline: str = ...,
tags: list = ...,
list: str = ...,
heading: str = ...,
creation_date: str = ...,
completion_date: str = ...) -> None:
arguments = locals()
token = arguments.pop('auth_token')
arguments['auth-token'] = token
id = arguments.pop('task_id')
arguments['id'] = id
if prepend_notes:
arguments.pop('prepend_notes')
arguments['prepend-notes'] = True
if append_notes:
arguments.pop('append_notes')
arguments['append-notes'] = True
if checklist_items != Ellipsis:
checklist = arguments.pop('checklist_items')
arguments['checklist-items'] = '\n'.join(checklist)
if tags != Ellipsis:
arguments['tags'] = ','.join(tags)
parameters = [f"{k}={v}" for k, v in arguments.items() if v != Ellipsis]
params = '&'.join(parameters)
base_url = "things:///update?reveal=False&"
subprocess.run(['open', f"{base_url + params}"])
heading: str = "TASK UPDATED BY MAKETHINGS"
logging.info(f"\n{heading:-^54}\nTitle: {title}")