things-py 0.0.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: things.py
3
- Version: 0.0.3
3
+ Version: 0.0.5
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.
@@ -8,16 +8,16 @@ Author-email: alex@willner.ws
8
8
  License: UNKNOWN
9
9
  Description: # Things Python API
10
10
 
11
- A simple Python 3 library to read your [Things app](https://culturedcode.com/things) data.
11
+ A simple Python 3 library to read your [Things app](https://culturedcode.com/things) data. You can test the API [via our CLI](https://github.com/thingsapi/things-cli).
12
12
 
13
13
  [![Build Status](https://github.com/thingsapi/things.py/workflows/Build-Test/badge.svg)](https://github.com/thingsapi/things.py/actions)
14
+ [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/quality/g/thingsapi/things.py)](https://scrutinizer-ci.com/g/thingsapi/things.py/?branch=master)
14
15
  [![Coverage Status](https://codecov.io/gh/thingsapi/things.py/branch/main/graph/badge.svg?token=DBWGKAEYAP)](https://codecov.io/gh/thingsapi/things.py)
15
- [![GitHub Release](https://img.shields.io/github/v/release/thingsapi/things.py?sort=semver)](https://github.com/thingsapi/things.py/releases)
16
+ [![GitHub Issues](https://img.shields.io/github/issues/thingsapi/things.py)](https://github.com/thingsapi/things.py/issues)
16
17
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
18
+ [![GitHub Release](https://img.shields.io/github/v/release/thingsapi/things.py?sort=semver)](https://github.com/thingsapi/things.py/releases)
17
19
  [![PyPI - Downloads](https://img.shields.io/pypi/dm/things.py?label=pypi%20downloads)](https://pypi.org/project/things.py/)
18
20
  [![GitHub Download Count](https://img.shields.io/github/downloads/thingsapi/things.py/total.svg)](https://github.com/thingsapi/things.py/releases)
19
- [![GitHub Issues](https://img.shields.io/github/issues/thingsapi/things.py)](https://github.com/thingsapi/things.py/issues)
20
- [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/quality/g/thingsapi/things.py)](https://scrutinizer-ci.com/g/thingsapi/things.py/?branch=master)
21
21
 
22
22
  ## Table of Contents
23
23
 
@@ -1,15 +1,15 @@
1
1
  # Things Python API
2
2
 
3
- A simple Python 3 library to read your [Things app](https://culturedcode.com/things) data.
3
+ A simple Python 3 library to read your [Things app](https://culturedcode.com/things) data. You can test the API [via our CLI](https://github.com/thingsapi/things-cli).
4
4
 
5
5
  [![Build Status](https://github.com/thingsapi/things.py/workflows/Build-Test/badge.svg)](https://github.com/thingsapi/things.py/actions)
6
+ [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/quality/g/thingsapi/things.py)](https://scrutinizer-ci.com/g/thingsapi/things.py/?branch=master)
6
7
  [![Coverage Status](https://codecov.io/gh/thingsapi/things.py/branch/main/graph/badge.svg?token=DBWGKAEYAP)](https://codecov.io/gh/thingsapi/things.py)
7
- [![GitHub Release](https://img.shields.io/github/v/release/thingsapi/things.py?sort=semver)](https://github.com/thingsapi/things.py/releases)
8
+ [![GitHub Issues](https://img.shields.io/github/issues/thingsapi/things.py)](https://github.com/thingsapi/things.py/issues)
8
9
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
10
+ [![GitHub Release](https://img.shields.io/github/v/release/thingsapi/things.py?sort=semver)](https://github.com/thingsapi/things.py/releases)
9
11
  [![PyPI - Downloads](https://img.shields.io/pypi/dm/things.py?label=pypi%20downloads)](https://pypi.org/project/things.py/)
10
12
  [![GitHub Download Count](https://img.shields.io/github/downloads/thingsapi/things.py/total.svg)](https://github.com/thingsapi/things.py/releases)
11
- [![GitHub Issues](https://img.shields.io/github/issues/thingsapi/things.py)](https://github.com/thingsapi/things.py/issues)
12
- [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/quality/g/thingsapi/things.py)](https://scrutinizer-ci.com/g/thingsapi/things.py/?branch=master)
13
13
 
14
14
  ## Table of Contents
15
15
 
@@ -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.3"
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(1, len(tasks))
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 antime."""
52
+ """Test anytime."""
46
53
  tasks = things.anytime(**FILEPATH)
47
- self.assertEqual(8, len(tasks))
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(5, len(tasks))
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(9, len(tasks))
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(13, len(tasks))
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(1, len(test_areas))
114
+ self.assertEqual(3, len(test_areas))
107
115
 
108
116
  def test_database_version(self):
109
117
  """Test database version."""
@@ -4,6 +4,7 @@ from things.api import ( # noqa
4
4
  anytime,
5
5
  areas,
6
6
  canceled,
7
+ checklist_items,
7
8
  completed,
8
9
  deadlines,
9
10
  get,
@@ -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
  --------
@@ -386,17 +389,44 @@ def get(uuid, default=None, **kwargs):
386
389
 
387
390
 
388
391
  def todos(uuid=None, **kwargs):
392
+ """
393
+ Read to-dos into dicts.
394
+
395
+ See `things.api.tasks` for details.
396
+ """
389
397
  return tasks(uuid=uuid, type="to-do", **kwargs)
390
398
 
391
399
 
392
400
  def projects(uuid=None, **kwargs):
401
+ """
402
+ Read projects into dicts.
403
+
404
+ See `things.api.tasks` for details.
405
+ """
393
406
  return tasks(uuid=uuid, type="project", **kwargs)
394
407
 
395
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
+
396
421
  # Filter by collections in the Things app sidebar.
397
422
 
398
423
 
399
424
  def inbox(**kwargs):
425
+ """
426
+ Read inbox into dicts.
427
+
428
+ See `things.api.tasks` for details.
429
+ """
400
430
  return tasks(start="Inbox", **kwargs)
401
431
 
402
432
 
@@ -434,14 +464,29 @@ def upcoming(**kwargs):
434
464
 
435
465
 
436
466
  def anytime(**kwargs):
467
+ """
468
+ Read anytime tasks into dicts.
469
+
470
+ See `things.api.tasks` for details.
471
+ """
437
472
  return tasks(start="Anytime", **kwargs)
438
473
 
439
474
 
440
475
  def someday(**kwargs):
476
+ """
477
+ Read someday tasks into dicts.
478
+
479
+ See `things.api.tasks` for details.
480
+ """
441
481
  return tasks(start_date=False, start="Someday", **kwargs)
442
482
 
443
483
 
444
484
  def logbook(**kwargs):
485
+ """
486
+ Read logbook tasks into dicts.
487
+
488
+ See `things.api.tasks` for details.
489
+ """
445
490
  result = [*canceled(**kwargs), *completed(**kwargs)]
446
491
  result.sort(key=lambda task: task["stop_date"], reverse=True)
447
492
  return result
@@ -451,6 +496,11 @@ def logbook(**kwargs):
451
496
 
452
497
 
453
498
  def canceled(**kwargs):
499
+ """
500
+ Read canceled tasks into dicts.
501
+
502
+ See `things.api.tasks` for details.
503
+ """
454
504
  return tasks(status="canceled", **kwargs)
455
505
 
456
506
 
@@ -467,6 +517,11 @@ def completed(**kwargs):
467
517
 
468
518
 
469
519
  def deadlines(**kwargs):
520
+ """
521
+ Read tasks with deadlines into dicts.
522
+
523
+ See `things.api.tasks` for details.
524
+ """
470
525
  result = tasks(deadline=True, **kwargs)
471
526
  result.sort(key=lambda task: task["deadline"])
472
527
  return result
@@ -476,6 +531,10 @@ def deadlines(**kwargs):
476
531
 
477
532
 
478
533
  def link(uuid):
534
+ """
535
+ Returns a things:///show?id=uuid link.
536
+ """
537
+
479
538
  return f"things:///show?id={uuid}"
480
539
 
481
540
 
@@ -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__ = "2.6.3"
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
- else:
296
- return self.execute_query(sql_query)
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."""
@@ -530,7 +540,7 @@ class Database:
530
540
  "+" || x || " days") as date,
531
541
  CREATED.TasksCreated as created,
532
542
  CLOSED.TasksClosed as completed,
533
- CANCELLED.TasksCanceled as canceled,
543
+ CANCELED.TasksCanceled as canceled,
534
544
  TRASHED.TasksTrashed as trashed
535
545
  FROM timeseries
536
546
  LEFT JOIN
@@ -548,7 +558,7 @@ class Database:
548
558
  WHERE DAY NOT NULL
549
559
  AND TASK.{self.IS_CANCELED} AND TASK.{self.IS_TODO}
550
560
  GROUP BY DAY)
551
- AS CANCELLED ON CANCELLED.DAY = date
561
+ AS CANCELED ON CANCELED.DAY = date
552
562
  LEFT JOIN
553
563
  (SELECT COUNT(uuid) AS TasksTrashed,
554
564
  date({self.DATE_MOD},"unixepoch") AS DAY
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: things.py
3
- Version: 0.0.3
3
+ Version: 0.0.5
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.
@@ -8,16 +8,16 @@ Author-email: alex@willner.ws
8
8
  License: UNKNOWN
9
9
  Description: # Things Python API
10
10
 
11
- A simple Python 3 library to read your [Things app](https://culturedcode.com/things) data.
11
+ A simple Python 3 library to read your [Things app](https://culturedcode.com/things) data. You can test the API [via our CLI](https://github.com/thingsapi/things-cli).
12
12
 
13
13
  [![Build Status](https://github.com/thingsapi/things.py/workflows/Build-Test/badge.svg)](https://github.com/thingsapi/things.py/actions)
14
+ [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/quality/g/thingsapi/things.py)](https://scrutinizer-ci.com/g/thingsapi/things.py/?branch=master)
14
15
  [![Coverage Status](https://codecov.io/gh/thingsapi/things.py/branch/main/graph/badge.svg?token=DBWGKAEYAP)](https://codecov.io/gh/thingsapi/things.py)
15
- [![GitHub Release](https://img.shields.io/github/v/release/thingsapi/things.py?sort=semver)](https://github.com/thingsapi/things.py/releases)
16
+ [![GitHub Issues](https://img.shields.io/github/issues/thingsapi/things.py)](https://github.com/thingsapi/things.py/issues)
16
17
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
18
+ [![GitHub Release](https://img.shields.io/github/v/release/thingsapi/things.py?sort=semver)](https://github.com/thingsapi/things.py/releases)
17
19
  [![PyPI - Downloads](https://img.shields.io/pypi/dm/things.py?label=pypi%20downloads)](https://pypi.org/project/things.py/)
18
20
  [![GitHub Download Count](https://img.shields.io/github/downloads/thingsapi/things.py/total.svg)](https://github.com/thingsapi/things.py/releases)
19
- [![GitHub Issues](https://img.shields.io/github/issues/thingsapi/things.py)](https://github.com/thingsapi/things.py/issues)
20
- [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/quality/g/thingsapi/things.py)](https://scrutinizer-ci.com/g/thingsapi/things.py/?branch=master)
21
21
 
22
22
  ## Table of Contents
23
23
 
File without changes
File without changes