things-py 0.0.4__tar.gz → 0.0.5__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.
- {things.py-0.0.4 → things.py-0.0.5}/PKG-INFO +1 -1
- {things.py-0.0.4 → things.py-0.0.5}/setup.py +1 -1
- {things.py-0.0.4 → things.py-0.0.5}/tests/test_things.py +15 -7
- {things.py-0.0.4 → things.py-0.0.5}/things/__init__.py +1 -0
- {things.py-0.0.4 → things.py-0.0.5}/things/api.py +30 -15
- {things.py-0.0.4 → things.py-0.0.5}/things/database.py +16 -6
- {things.py-0.0.4 → things.py-0.0.5}/things.py.egg-info/PKG-INFO +1 -1
- {things.py-0.0.4 → things.py-0.0.5}/README.md +0 -0
- {things.py-0.0.4 → things.py-0.0.5}/setup.cfg +0 -0
- {things.py-0.0.4 → things.py-0.0.5}/tests/__init__.py +0 -0
- {things.py-0.0.4 → things.py-0.0.5}/things.py.egg-info/SOURCES.txt +0 -0
- {things.py-0.0.4 → things.py-0.0.5}/things.py.egg-info/dependency_links.txt +0 -0
- {things.py-0.0.4 → things.py-0.0.5}/things.py.egg-info/top_level.txt +0 -0
|
@@ -20,7 +20,7 @@ AUTHOR = "Alexander Willner, Michael B."
|
|
|
20
20
|
AUTHOR_MAIL = "alex@willner.ws"
|
|
21
21
|
DESCRIPTON = "A simple Python 3 library to read your Things app data."
|
|
22
22
|
URL = "https://github.com/thingsapi/things.py"
|
|
23
|
-
VERSION = "0.0.
|
|
23
|
+
VERSION = "0.0.5"
|
|
24
24
|
DATA_FILES = package_files("")
|
|
25
25
|
OPTIONS = {
|
|
26
26
|
"argv_emulation": False,
|
|
@@ -24,7 +24,7 @@ class ThingsCase(unittest.TestCase):
|
|
|
24
24
|
def test_inbox(self):
|
|
25
25
|
"""Test inbox."""
|
|
26
26
|
tasks = things.inbox(**FILEPATH)
|
|
27
|
-
self.assertEqual(
|
|
27
|
+
self.assertEqual(2, len(tasks))
|
|
28
28
|
|
|
29
29
|
def test_upcoming(self):
|
|
30
30
|
"""Test upcoming."""
|
|
@@ -41,10 +41,18 @@ class ThingsCase(unittest.TestCase):
|
|
|
41
41
|
tasks = things.today(**FILEPATH)
|
|
42
42
|
self.assertEqual(1, len(tasks))
|
|
43
43
|
|
|
44
|
+
def test_checklist(self):
|
|
45
|
+
"""Test checklist."""
|
|
46
|
+
tasks = things.checklist_items('3Eva4XFof6zWb9iSfYy4ej', **FILEPATH)
|
|
47
|
+
self.assertEqual(3, len(tasks))
|
|
48
|
+
tasks = things.checklist_items('K9bx7h1xCJdevvyWardZDq', **FILEPATH)
|
|
49
|
+
self.assertEqual(0, len(tasks))
|
|
50
|
+
|
|
44
51
|
def test_anytime(self):
|
|
45
|
-
"""Test
|
|
52
|
+
"""Test anytime."""
|
|
46
53
|
tasks = things.anytime(**FILEPATH)
|
|
47
|
-
self.assertEqual(
|
|
54
|
+
self.assertEqual(10, len(tasks))
|
|
55
|
+
self.assertTrue(any(task.pop('area_title', '') == 'Area 1' for task in tasks))
|
|
48
56
|
|
|
49
57
|
def test_logbook(self):
|
|
50
58
|
"""Test logbook."""
|
|
@@ -78,17 +86,17 @@ class ThingsCase(unittest.TestCase):
|
|
|
78
86
|
def test_todos(self):
|
|
79
87
|
"""Test all tasks."""
|
|
80
88
|
tasks = things.todos(start="Anytime", **FILEPATH)
|
|
81
|
-
self.assertEqual(
|
|
89
|
+
self.assertEqual(7, len(tasks))
|
|
82
90
|
tasks = things.todos(start="Anytime", status="completed", **FILEPATH)
|
|
83
91
|
self.assertEqual(6, len(tasks))
|
|
84
92
|
tasks = things.todos(status="completed", **FILEPATH)
|
|
85
93
|
self.assertEqual(10, len(tasks))
|
|
86
94
|
tasks = things.todos(include_items=True, **FILEPATH)
|
|
87
|
-
self.assertEqual(
|
|
95
|
+
self.assertEqual(12, len(tasks))
|
|
88
96
|
with self.assertRaises(ValueError):
|
|
89
97
|
things.todos(status="wrong_value", **FILEPATH)
|
|
90
98
|
tasks = things.tasks("A2oPvtt4dXoypeoLc8uYzY", **FILEPATH)
|
|
91
|
-
self.assertEqual(
|
|
99
|
+
self.assertEqual(14, len(tasks))
|
|
92
100
|
|
|
93
101
|
def test_tags(self):
|
|
94
102
|
"""Test all tags."""
|
|
@@ -103,7 +111,7 @@ class ThingsCase(unittest.TestCase):
|
|
|
103
111
|
def test_areas(self):
|
|
104
112
|
"""Test all test_areas."""
|
|
105
113
|
test_areas = things.areas(**FILEPATH)
|
|
106
|
-
self.assertEqual(
|
|
114
|
+
self.assertEqual(3, len(test_areas))
|
|
107
115
|
|
|
108
116
|
def test_database_version(self):
|
|
109
117
|
"""Test database version."""
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
Module implementing Things API.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
+
__version__ = "0.0.5"
|
|
8
|
+
|
|
7
9
|
import os
|
|
8
10
|
from shlex import quote
|
|
9
11
|
import sys
|
|
@@ -112,9 +114,10 @@ def tasks(uuid=None, include_items=False, **kwargs): # noqa: C901
|
|
|
112
114
|
filepath : str, optional
|
|
113
115
|
Any valid path of a SQLite database file generated by the Things app.
|
|
114
116
|
If no path is provided, then access the default database path.
|
|
117
|
+
If environment variable THINGSDB is set, this path will be used.
|
|
115
118
|
|
|
116
|
-
database : things.Database, optional
|
|
117
|
-
Any valid `things.Database` object previously instantiated.
|
|
119
|
+
database : things.database.Database, optional
|
|
120
|
+
Any valid `things.database.Database` object previously instantiated.
|
|
118
121
|
|
|
119
122
|
Returns
|
|
120
123
|
-------
|
|
@@ -214,8 +217,8 @@ def areas(uuid=None, include_items=False, **kwargs):
|
|
|
214
217
|
Any valid path of a SQLite database file generated by the Things app.
|
|
215
218
|
If no path is provided, then access the default database path.
|
|
216
219
|
|
|
217
|
-
database : things.Database, optional
|
|
218
|
-
Any valid `things.Database` object previously instantiated.
|
|
220
|
+
database : things.database.Database, optional
|
|
221
|
+
Any valid `things.database.Database` object previously instantiated.
|
|
219
222
|
|
|
220
223
|
Returns
|
|
221
224
|
-------
|
|
@@ -284,8 +287,8 @@ def tags(title=None, include_items=False, **kwargs):
|
|
|
284
287
|
Any valid path of a SQLite database file generated by the Things app.
|
|
285
288
|
If no path is provided, then access the default database path.
|
|
286
289
|
|
|
287
|
-
database : things.Database, optional
|
|
288
|
-
Any valid `things.Database` object previously instantiated.
|
|
290
|
+
database : things.database.Database, optional
|
|
291
|
+
Any valid `things.database.Database` object previously instantiated.
|
|
289
292
|
|
|
290
293
|
Returns
|
|
291
294
|
-------
|
|
@@ -336,7 +339,7 @@ def search(query: str, **kwargs) -> List[Dict]:
|
|
|
336
339
|
Currently any part of a title and note of a to-do, project,
|
|
337
340
|
heading, or area is matched.
|
|
338
341
|
|
|
339
|
-
See the `search_query` parameter of `api.tasks` for details.
|
|
342
|
+
See the `search_query` parameter of `things.api.tasks` for details.
|
|
340
343
|
|
|
341
344
|
Examples
|
|
342
345
|
--------
|
|
@@ -389,7 +392,7 @@ def todos(uuid=None, **kwargs):
|
|
|
389
392
|
"""
|
|
390
393
|
Read to-dos into dicts.
|
|
391
394
|
|
|
392
|
-
See `things.tasks` for details.
|
|
395
|
+
See `things.api.tasks` for details.
|
|
393
396
|
"""
|
|
394
397
|
return tasks(uuid=uuid, type="to-do", **kwargs)
|
|
395
398
|
|
|
@@ -398,11 +401,23 @@ def projects(uuid=None, **kwargs):
|
|
|
398
401
|
"""
|
|
399
402
|
Read projects into dicts.
|
|
400
403
|
|
|
401
|
-
See `things.tasks` for details.
|
|
404
|
+
See `things.api.tasks` for details.
|
|
402
405
|
"""
|
|
403
406
|
return tasks(uuid=uuid, type="project", **kwargs)
|
|
404
407
|
|
|
405
408
|
|
|
409
|
+
def checklist_items(uuid, **kwargs):
|
|
410
|
+
"""
|
|
411
|
+
Read checklist items into dicts.
|
|
412
|
+
See `things.api.tasks` for details.
|
|
413
|
+
|
|
414
|
+
Returns
|
|
415
|
+
-------
|
|
416
|
+
list of dict
|
|
417
|
+
Representing checklist items. Or [] if none found.
|
|
418
|
+
"""
|
|
419
|
+
return tasks(uuid=uuid, type="to-do", **kwargs).get('checklist', [])
|
|
420
|
+
|
|
406
421
|
# Filter by collections in the Things app sidebar.
|
|
407
422
|
|
|
408
423
|
|
|
@@ -410,7 +425,7 @@ def inbox(**kwargs):
|
|
|
410
425
|
"""
|
|
411
426
|
Read inbox into dicts.
|
|
412
427
|
|
|
413
|
-
See `things.tasks` for details.
|
|
428
|
+
See `things.api.tasks` for details.
|
|
414
429
|
"""
|
|
415
430
|
return tasks(start="Inbox", **kwargs)
|
|
416
431
|
|
|
@@ -452,7 +467,7 @@ def anytime(**kwargs):
|
|
|
452
467
|
"""
|
|
453
468
|
Read anytime tasks into dicts.
|
|
454
469
|
|
|
455
|
-
See `things.tasks` for details.
|
|
470
|
+
See `things.api.tasks` for details.
|
|
456
471
|
"""
|
|
457
472
|
return tasks(start="Anytime", **kwargs)
|
|
458
473
|
|
|
@@ -461,7 +476,7 @@ def someday(**kwargs):
|
|
|
461
476
|
"""
|
|
462
477
|
Read someday tasks into dicts.
|
|
463
478
|
|
|
464
|
-
See `things.tasks` for details.
|
|
479
|
+
See `things.api.tasks` for details.
|
|
465
480
|
"""
|
|
466
481
|
return tasks(start_date=False, start="Someday", **kwargs)
|
|
467
482
|
|
|
@@ -470,7 +485,7 @@ def logbook(**kwargs):
|
|
|
470
485
|
"""
|
|
471
486
|
Read logbook tasks into dicts.
|
|
472
487
|
|
|
473
|
-
See `things.tasks` for details.
|
|
488
|
+
See `things.api.tasks` for details.
|
|
474
489
|
"""
|
|
475
490
|
result = [*canceled(**kwargs), *completed(**kwargs)]
|
|
476
491
|
result.sort(key=lambda task: task["stop_date"], reverse=True)
|
|
@@ -484,7 +499,7 @@ def canceled(**kwargs):
|
|
|
484
499
|
"""
|
|
485
500
|
Read canceled tasks into dicts.
|
|
486
501
|
|
|
487
|
-
See `things.tasks` for details.
|
|
502
|
+
See `things.api.tasks` for details.
|
|
488
503
|
"""
|
|
489
504
|
return tasks(status="canceled", **kwargs)
|
|
490
505
|
|
|
@@ -505,7 +520,7 @@ def deadlines(**kwargs):
|
|
|
505
520
|
"""
|
|
506
521
|
Read tasks with deadlines into dicts.
|
|
507
522
|
|
|
508
|
-
See `things.tasks` for details.
|
|
523
|
+
See `things.api.tasks` for details.
|
|
509
524
|
"""
|
|
510
525
|
result = tasks(deadline=True, **kwargs)
|
|
511
526
|
result.sort(key=lambda task: task["deadline"])
|
|
@@ -13,7 +13,7 @@ __author__ = "Alexander Willner"
|
|
|
13
13
|
__copyright__ = "2020 Alexander Willner"
|
|
14
14
|
__credits__ = ["Alexander Willner"]
|
|
15
15
|
__license__ = "Apache License 2.0"
|
|
16
|
-
__version__ = "
|
|
16
|
+
__version__ = "0.0.5"
|
|
17
17
|
__maintainer__ = "Alexander Willner"
|
|
18
18
|
__email__ = "alex@willner.ws"
|
|
19
19
|
__status__ = "Development"
|
|
@@ -22,6 +22,7 @@ import datetime
|
|
|
22
22
|
import os
|
|
23
23
|
import sqlite3
|
|
24
24
|
import sys
|
|
25
|
+
from os import environ
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
DEFAULT_DATABASE_FILEPATH = os.path.expanduser(
|
|
@@ -45,7 +46,7 @@ TYPE_TO_FILTER = {"to-do": "type = 0", "project": "type = 1", "heading": "type =
|
|
|
45
46
|
|
|
46
47
|
INDICES = ("index", "todayIndex")
|
|
47
48
|
|
|
48
|
-
COLUMNS_TO_OMIT_IF_NONE = ("area", "project", "heading", "trashed", "checklist", "tags")
|
|
49
|
+
COLUMNS_TO_OMIT_IF_NONE = ("area", "area_title", "project", "project_title", "heading", "heading_title", "trashed", "checklist", "tags")
|
|
49
50
|
COLUMNS_TO_TRANSFORM_TO_BOOL = ("trashed", "checklist", "tags")
|
|
50
51
|
|
|
51
52
|
|
|
@@ -99,7 +100,7 @@ class Database:
|
|
|
99
100
|
|
|
100
101
|
# pylint: disable=R0913
|
|
101
102
|
def __init__(self, filepath=None):
|
|
102
|
-
self.filepath = filepath or DEFAULT_DATABASE_FILEPATH
|
|
103
|
+
self.filepath = filepath or environ.get("THINGSDB") or DEFAULT_DATABASE_FILEPATH
|
|
103
104
|
|
|
104
105
|
# Automated migration to new database location in Things 3.12.6/3.13.1
|
|
105
106
|
# --------------------------------
|
|
@@ -206,12 +207,21 @@ class Database:
|
|
|
206
207
|
CASE
|
|
207
208
|
WHEN AREA.uuid IS NOT NULL THEN AREA.uuid
|
|
208
209
|
END AS area,
|
|
210
|
+
CASE
|
|
211
|
+
WHEN AREA.uuid IS NOT NULL THEN AREA.title
|
|
212
|
+
END AS area_title,
|
|
209
213
|
CASE
|
|
210
214
|
WHEN PROJECT.uuid IS NOT NULL THEN PROJECT.uuid
|
|
211
215
|
END AS project,
|
|
216
|
+
CASE
|
|
217
|
+
WHEN PROJECT.uuid IS NOT NULL THEN PROJECT.title
|
|
218
|
+
END AS project_title,
|
|
212
219
|
CASE
|
|
213
220
|
WHEN HEADING.uuid IS NOT NULL THEN HEADING.uuid
|
|
214
221
|
END AS heading,
|
|
222
|
+
CASE
|
|
223
|
+
WHEN HEADING.uuid IS NOT NULL THEN HEADING.title
|
|
224
|
+
END AS heading_title,
|
|
215
225
|
TASK.notes,
|
|
216
226
|
CASE
|
|
217
227
|
WHEN TAG.uuid IS NOT NULL THEN 1
|
|
@@ -272,7 +282,7 @@ class Database:
|
|
|
272
282
|
# Query
|
|
273
283
|
sql_query = f"""
|
|
274
284
|
SELECT
|
|
275
|
-
AREA.uuid,
|
|
285
|
+
DISTINCT AREA.uuid,
|
|
276
286
|
'area' as type,
|
|
277
287
|
AREA.title,
|
|
278
288
|
CASE
|
|
@@ -292,8 +302,8 @@ class Database:
|
|
|
292
302
|
"""
|
|
293
303
|
if count_only:
|
|
294
304
|
return self.get_count(sql_query)
|
|
295
|
-
|
|
296
|
-
|
|
305
|
+
|
|
306
|
+
return self.execute_query(sql_query)
|
|
297
307
|
|
|
298
308
|
def get_checklist_items(self, task_uuid=None):
|
|
299
309
|
"""Get checklist items."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|