things-py 0.0.9.dev0__tar.gz → 0.0.11__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: things.py
3
- Version: 0.0.9.dev0
3
+ Version: 0.0.11
4
4
  Summary: A simple Python 3 library to read your Things app data.
5
5
  Home-page: https://github.com/thingsapi/things.py
6
6
  Author: Alexander Willner, Michael B.
@@ -13,6 +13,10 @@ ignore = E501,E203,W503
13
13
  [pylama]
14
14
  ignore = E501,E203,W503
15
15
 
16
+ [isort]
17
+ lines_after_imports = 2
18
+ force_sort_within_sections = True
19
+
16
20
  [egg_info]
17
21
  tag_build =
18
22
  tag_date = 0
@@ -1,7 +1,8 @@
1
1
  """A simple Python 3 library to read your Things app data."""
2
2
 
3
3
  import os
4
- from setuptools import setup, find_packages # type: ignore
4
+
5
+ from setuptools import find_packages, setup # type: ignore
5
6
 
6
7
 
7
8
  def package_files(directory):
@@ -3,6 +3,8 @@
3
3
 
4
4
  """Module documentation goes here."""
5
5
 
6
+ import contextlib
7
+ import io
6
8
  import os
7
9
  import unittest
8
10
 
@@ -48,14 +50,49 @@ class ThingsCase(unittest.TestCase):
48
50
  """Test search."""
49
51
  tasks = things.search("wrong_query")
50
52
  self.assertEqual(0, len(tasks))
51
- tasks = things.search("To-Do % Heading")
52
- self.assertEqual(1, len(tasks))
53
+
54
+ # test some special characters
55
+ tasks = things.search("'")
56
+ self.assertEqual(0, len(tasks))
57
+
58
+ tasks = things.search('"')
59
+ self.assertEqual(0, len(tasks))
60
+
61
+ with self.assertRaises(ValueError):
62
+ things.search("To-Do\0Heading")
63
+
64
+ todos = things.search("To-Do % Heading", status=None)
65
+ # Assert finds
66
+ # "To-Do in Heading",
67
+ # "Completed To-Do in Heading",
68
+ # "Canceled To-Do in Heading"
69
+ self.assertEqual(3, len(todos))
53
70
 
54
71
  def test_inbox(self):
55
72
  """Test inbox."""
56
73
  tasks = things.inbox()
57
74
  self.assertEqual(2, len(tasks))
58
75
 
76
+ def test_trashed(self):
77
+ """Test getting trashed tasks."""
78
+ tasks = things.trash()
79
+ self.assertEqual(5, len(tasks))
80
+ todos = things.todos(trashed=True)
81
+ self.assertEqual(2, len(todos))
82
+ projects = things.projects(trashed=True)
83
+ self.assertEqual(1, len(projects))
84
+ projects = things.projects(trashed=None)
85
+ self.assertEqual(4, len(projects))
86
+ projects = things.trash(type="project")
87
+ self.assertEqual(1, len(projects))
88
+ projects = things.trash(type="project", include_items=True)
89
+ # TOOD: doesn't inlucde items
90
+ # self.assertEqual(1, len(projects[0]["items"]))
91
+ # tasks = list(
92
+ # filter(lambda _: "in Deleted Project" in _["title"], projects[0]["items"])
93
+ # )
94
+ # self.assertEqual(1, len(tasks))
95
+
59
96
  def test_upcoming(self):
60
97
  """Test upcoming."""
61
98
  tasks = things.upcoming()
@@ -69,7 +106,7 @@ class ThingsCase(unittest.TestCase):
69
106
  def test_today(self):
70
107
  """Test today."""
71
108
  tasks = things.today()
72
- self.assertEqual(2, len(tasks))
109
+ self.assertEqual(3, len(tasks))
73
110
 
74
111
  def test_checklist(self):
75
112
  """Test checklist."""
@@ -81,7 +118,7 @@ class ThingsCase(unittest.TestCase):
81
118
  def test_anytime(self):
82
119
  """Test anytime."""
83
120
  tasks = things.anytime()
84
- self.assertEqual(11, len(tasks))
121
+ self.assertEqual(12, len(tasks))
85
122
  self.assertTrue(any(task.get("area_title") == "Area 1" for task in tasks))
86
123
 
87
124
  def test_logbook(self):
@@ -123,6 +160,8 @@ class ThingsCase(unittest.TestCase):
123
160
  self.assertEqual(10, len(todos))
124
161
  todos = things.todos(include_items=True)
125
162
  self.assertEqual(12, len(todos))
163
+ tasks = things.tasks(include_items=True)
164
+ self.assertEqual(16, len(tasks))
126
165
  with self.assertRaises(ValueError):
127
166
  things.todos(status="wrong_value")
128
167
  todo = things.todos("A2oPvtt4dXoypeoLc8uYzY")
@@ -132,18 +171,36 @@ class ThingsCase(unittest.TestCase):
132
171
  """Test all tags."""
133
172
  tags = things.tags()
134
173
  self.assertEqual(5, len(tags))
135
- tasks = things.tasks(tag="Errand")
136
- self.assertEqual(1, len(tasks))
174
+ tags = things.tags(include_items=True)
175
+ self.assertEqual(5, len(tags))
176
+ tags = things.tasks(tag="Errand")
177
+ self.assertEqual(1, len(tags))
178
+ tag = things.tags(title="Errand")
179
+ self.assertEqual("Errand", tag["title"])
180
+
181
+ def test_get_link(self):
182
+ link = things.link("uuid")
183
+ self.assertEqual("things:///show?id=uuid", link)
137
184
 
138
185
  def test_projects(self):
139
186
  """Test all projects."""
140
187
  projects = things.projects()
141
- self.assertEqual(2, len(projects))
188
+ self.assertEqual(3, len(projects))
189
+ projects = things.projects(include_items=True)
190
+ self.assertEqual(2, len(projects[0]["items"]))
142
191
 
143
192
  def test_areas(self):
144
193
  """Test all test_areas."""
145
194
  areas = things.areas()
146
195
  self.assertEqual(3, len(areas))
196
+ areas = things.areas(include_items=True)
197
+ self.assertEqual(3, len(areas))
198
+ count = things.areas(count_only=True)
199
+ self.assertEqual(3, count)
200
+ with self.assertRaises(ValueError):
201
+ things.areas("wrong-uuid")
202
+ area = things.areas("Y3JC4XeyGWxzDocQL4aobo")
203
+ self.assertEqual("Area 3", area["title"])
147
204
 
148
205
  def test_database_version(self):
149
206
  """Test database version."""
@@ -152,11 +209,11 @@ class ThingsCase(unittest.TestCase):
152
209
 
153
210
  def test_last(self):
154
211
  """Test last parameter"""
155
- last_tasks = things.last("1d")
212
+ last_tasks = things.last("0d")
156
213
  self.assertEqual(len(last_tasks), 0)
157
214
 
158
215
  last_tasks = things.last("10000w")
159
- self.assertEqual(len(last_tasks), 15)
216
+ self.assertEqual(len(last_tasks), 16)
160
217
 
161
218
  last_tasks = things.last("100y", status="completed")
162
219
  self.assertEqual(len(last_tasks), 10)
@@ -164,6 +221,9 @@ class ThingsCase(unittest.TestCase):
164
221
  with self.assertRaises(ValueError):
165
222
  things.last(None)
166
223
 
224
+ with self.assertRaises(ValueError):
225
+ things.last([])
226
+
167
227
  with self.assertRaises(ValueError):
168
228
  things.last("XYZ")
169
229
 
@@ -177,6 +237,29 @@ class ThingsCase(unittest.TestCase):
177
237
  """Test tasks"""
178
238
  count = things.tasks(status="completed", last="100y", count_only=True)
179
239
  self.assertEqual(count, 10)
240
+ # special characters
241
+ tasks = things.tasks(area='"')
242
+ self.assertEqual(len(tasks), 0)
243
+
244
+ tasks = things.tasks(area="'")
245
+ self.assertEqual(len(tasks), 0)
246
+
247
+ with self.assertRaises(ValueError):
248
+ things.tasks(area="\0")
249
+
250
+ def test_database(self):
251
+ """Test some database details"""
252
+ output = io.StringIO()
253
+ with contextlib.redirect_stdout(output):
254
+ db = things.api.pop_database({})
255
+ db.debug = True
256
+ db.get_tags()
257
+ self.assertTrue("H96sVJwE7VJveAnv7itmux" in output.getvalue())
258
+ with contextlib.redirect_stdout(output):
259
+ things.areas(print_sql=True)
260
+ self.assertTrue("ORDER BY" in output.getvalue())
261
+ with self.assertRaises(SystemExit): # noqa TODO: should actually NOT crash
262
+ db.execute_query('"')
180
263
 
181
264
 
182
265
  if __name__ == "__main__":
@@ -4,7 +4,7 @@ __author__ = ["Alexander Willner", "Michael Belfrage"]
4
4
  __copyright__ = "2021 Alexander Willner & Michael Belfrage"
5
5
  __credits__ = ["Alexander Willner", "Michael Belfrage"]
6
6
  __license__ = "Apache License 2.0"
7
- __version__ = "0.0.9.dev"
7
+ __version__ = "0.0.11"
8
8
  __maintainer__ = ["Alexander Willner", "Michael Belfrage"]
9
9
  __email__ = "alex@willner.ws"
10
10
  __status__ = "Development"
@@ -30,6 +30,7 @@ from things.api import ( # noqa
30
30
  today,
31
31
  todos,
32
32
  token,
33
+ trash,
33
34
  upcoming,
34
35
  )
35
36
  from things.database import Database # noqa
@@ -12,7 +12,7 @@ data structures. Whenever that happens, we define the new term here.
12
12
  import os
13
13
  from shlex import quote
14
14
  import sys
15
- from typing import Dict, List
15
+ from typing import Dict, List, Union
16
16
 
17
17
  from things.database import Database
18
18
 
@@ -98,14 +98,18 @@ def tasks(uuid=None, include_items=False, **kwargs): # noqa: C901
98
98
  - `deadline == True`, only include tasks _with_ a deadline.
99
99
  - `deadline == None` (default), then include all tasks.
100
100
 
101
- last : str, optional
102
- Limit returned tasks to tasks created in the last X days or weeks.
101
+ trashed : bool or None, optional
102
+ - `trashed == True`, only include trashed tasks.
103
+ - `trashed == False`, (default), only include non-trashed tasks.
104
+ - `trashed == None`, include both kind of tasks.
103
105
 
104
- Takes as input an offset string of format 'X[d/w]' where X is a
105
- non-negative integer that is followed by 'd' or 'w' which stand
106
- for 'days' and 'weeks', respectively.
106
+ last : str, optional
107
+ Limit returned tasks to tasks created within the last X days,
108
+ weeks, or years. For example: '3d', '5w', or '1y'.
107
109
 
108
- For example: '3d' or '5w'.
110
+ Takes as input an offset string of the format 'X[d/w/y]' where X
111
+ is a non-negative integer that is followed by 'd', 'w', or 'y'
112
+ which stand for 'days', 'weeks', and 'years', respectively.
109
113
 
110
114
  search_query : str, optional
111
115
  The string value is passed to the SQL LIKE operator. It can thus
@@ -121,6 +125,11 @@ def tasks(uuid=None, include_items=False, **kwargs): # noqa: C901
121
125
  count_only : bool, default False
122
126
  Only output length of result. This is done by a SQL COUNT query.
123
127
 
128
+ print_sql : bool, default False
129
+ Print every SQL query performed. Some may contain '?' and ':'
130
+ characters, which correspond to SQLite parameter tokens.
131
+ See https://www.sqlite.org/lang_expr.html#varparam
132
+
124
133
  filepath : str, optional
125
134
  Any valid path of a SQLite database file generated by the Things app.
126
135
  If the environment variable `THINGSDB` is set, then use that path.
@@ -178,7 +187,7 @@ def tasks(uuid=None, include_items=False, **kwargs): # noqa: C901
178
187
  # include items
179
188
  if task["type"] == "to-do":
180
189
  if task.get("checklist"):
181
- task["checklist"] = database.get_checklist_items(task_uuid=task["uuid"])
190
+ task["checklist"] = database.get_checklist_items(task["uuid"])
182
191
  elif task["type"] == "project":
183
192
  project = task
184
193
  project["items"] = items = tasks(
@@ -340,6 +349,27 @@ def tags(title=None, include_items=False, **kwargs):
340
349
  return result
341
350
 
342
351
 
352
+ def checklist_items(todo_uuid, **kwargs):
353
+ """
354
+ Read checklist items of to-dos into dicts.
355
+
356
+ Note: checklists are contained in the return value of
357
+ `things.todos(todo_uuid)` and `things.tasks(todo_uuid)`.
358
+
359
+ Parameters
360
+ ----------
361
+ todo_uuid : str, optional
362
+ A valid to-do uuid.
363
+
364
+ Returns
365
+ -------
366
+ list of dict
367
+ Checklist items.
368
+ """
369
+ database = pop_database(kwargs)
370
+ return database.get_checklist_items(todo_uuid=todo_uuid)
371
+
372
+
343
373
  # --------------------------------------------------
344
374
  # Utility API functions derived from above
345
375
  # --------------------------------------------------
@@ -419,26 +449,6 @@ def projects(uuid=None, **kwargs):
419
449
  return tasks(uuid=uuid, type="project", **kwargs)
420
450
 
421
451
 
422
- def checklist_items(uuid, **kwargs):
423
- """
424
- Read checklist items of a to-do into dicts.
425
-
426
- Note: this checklist is also contained in the return value of
427
- `things.todos(uuid)` and `things.tasks(uuid)`.
428
-
429
- Parameters
430
- ----------
431
- uuid : str
432
- A valid to-do uuid.
433
-
434
- Returns
435
- -------
436
- list of dict
437
- Checklist items of the to-do. If none, then return empty list.
438
- """
439
- return tasks(uuid=uuid, **kwargs).get("checklist", []) # type: ignore
440
-
441
-
442
452
  # Filter by collections in the Things app sidebar.
443
453
 
444
454
 
@@ -463,7 +473,7 @@ def today(**kwargs):
463
473
  See `things.api.tasks` for details on the optional parameters.
464
474
  """
465
475
  database = pop_database(kwargs)
466
- if not database.was_modified_today():
476
+ if not database.was_modified_today(): # pragma: no cover
467
477
  print(
468
478
  "[NOTE] The results reflect the state of the Things app "
469
479
  "when it was last run. If the results seem out of date, "
@@ -521,6 +531,15 @@ def logbook(**kwargs):
521
531
  return result
522
532
 
523
533
 
534
+ def trash(**kwargs):
535
+ """
536
+ Read Trash tasks into dicts.
537
+
538
+ See `things.api.tasks` for details on the optional parameters.
539
+ """
540
+ return tasks(trashed=True, status=kwargs.pop("status", None), **kwargs)
541
+
542
+
524
543
  # Filter by various task properties
525
544
 
526
545
 
@@ -602,7 +621,7 @@ def last(offset, **kwargs):
602
621
  # Interact with Things app
603
622
 
604
623
 
605
- def token(**kwargs) -> str:
624
+ def token(**kwargs) -> Union[str, None]:
606
625
  """
607
626
  Read the Things URL scheme authentication token.
608
627
 
@@ -636,8 +655,8 @@ def show(uuid):
636
655
  >>> tag = things.tags('Home')
637
656
  >>> things.show(tag['uuid'])
638
657
  """
639
- uri = link(uuid)
640
- os.system(f"open {quote(uri)}")
658
+ uri = link(uuid) # pragma: no cover
659
+ os.system(f"open {quote(uri)}") # pragma: no cover
641
660
 
642
661
 
643
662
  # Helper functions
@@ -645,7 +664,10 @@ def show(uuid):
645
664
 
646
665
  def pop_database(kwargs):
647
666
  """instantiate non-default database from `kwargs` if provided"""
648
- filepath, database = kwargs.pop("filepath", None), kwargs.pop("database", None)
667
+ filepath = kwargs.pop("filepath", None)
668
+ database = kwargs.pop("database", None)
669
+ print_sql = kwargs.pop("print_sql", False)
670
+
649
671
  if not database:
650
- database = Database(filepath=filepath)
672
+ database = Database(filepath=filepath, print_sql=print_sql)
651
673
  return database