taskli-cli 1.0.0__py3-none-any.whl
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.
- taskli/__init__.py +0 -0
- taskli/__version__.py +6 -0
- taskli/cli.py +1073 -0
- taskli/env.py +44 -0
- taskli/exceptions.py +74 -0
- taskli/hierarchy.py +88 -0
- taskli/logic.py +1099 -0
- taskli/migrations.py +165 -0
- taskli/models/__init__.py +1 -0
- taskli/models/attributes.py +140 -0
- taskli/models/config.py +111 -0
- taskli/models/dates.py +141 -0
- taskli/models/paths.py +21 -0
- taskli/models/query.py +250 -0
- taskli/models/registry.py +215 -0
- taskli/models/tasks.py +764 -0
- taskli/py.typed +0 -0
- taskli/render.py +520 -0
- taskli/storage.py +687 -0
- taskli_cli-1.0.0.data/data/share/taskli/completions/README.md +34 -0
- taskli_cli-1.0.0.data/data/share/taskli/completions/taskli.ps1 +38 -0
- taskli_cli-1.0.0.data/data/share/taskli/completions/taskli.sh +81 -0
- taskli_cli-1.0.0.dist-info/METADATA +208 -0
- taskli_cli-1.0.0.dist-info/RECORD +27 -0
- taskli_cli-1.0.0.dist-info/WHEEL +4 -0
- taskli_cli-1.0.0.dist-info/entry_points.txt +3 -0
- taskli_cli-1.0.0.dist-info/licenses/LICENSE +21 -0
taskli/env.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Storage-directory resolution and a dependency-free list-name scan."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
CONFIG_FILE_NAME = ".taskli.json"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def resolve_storage_dir() -> Path:
|
|
10
|
+
"""Return the directory task lists are stored in, creating it.
|
|
11
|
+
|
|
12
|
+
Returns
|
|
13
|
+
-------
|
|
14
|
+
Path
|
|
15
|
+
The storage directory, guaranteed to exist.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
path = Path(os.environ.get("TASKLI_PATH", Path.home() / ".taskli"))
|
|
19
|
+
storage_dir = path.expanduser()
|
|
20
|
+
|
|
21
|
+
storage_dir.mkdir(parents=True, exist_ok=True)
|
|
22
|
+
|
|
23
|
+
return storage_dir
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def scan_list_names(storage_dir: Path) -> list[str]:
|
|
27
|
+
"""Return the stems of all list files in the storage directory.
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
storage_dir : Path
|
|
32
|
+
The storage directory.
|
|
33
|
+
|
|
34
|
+
Returns
|
|
35
|
+
-------
|
|
36
|
+
list[str]
|
|
37
|
+
Sorted list names, excluding the config file.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
return sorted(
|
|
41
|
+
p.stem
|
|
42
|
+
for p in storage_dir.glob("*.json")
|
|
43
|
+
if p.name != CONFIG_FILE_NAME
|
|
44
|
+
)
|
taskli/exceptions.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""Taskli exceptions."""
|
|
2
|
+
|
|
3
|
+
__all__ = [
|
|
4
|
+
"TaskliError",
|
|
5
|
+
"ListNotFoundError",
|
|
6
|
+
"ListAlreadyExistsError",
|
|
7
|
+
"CorruptedListFileError",
|
|
8
|
+
"OutdatedListFileError",
|
|
9
|
+
"InvalidListNameError",
|
|
10
|
+
"ItemNotFoundError",
|
|
11
|
+
"TooManyAncestorListsError",
|
|
12
|
+
"UnknownConfigKeyError",
|
|
13
|
+
"InvalidConfigValueError",
|
|
14
|
+
"InvalidModifierValueError",
|
|
15
|
+
"InvalidReparentError",
|
|
16
|
+
"CorruptedConfigFileError",
|
|
17
|
+
"OutdatedConfigFileError",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class TaskliError(Exception):
|
|
22
|
+
"""Base for taskli errors."""
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ListNotFoundError(TaskliError):
|
|
26
|
+
"""Raised when a requested list file does not exist."""
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class ListAlreadyExistsError(TaskliError):
|
|
30
|
+
"""Raised when creating a list whose name is already in use."""
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class CorruptedListFileError(TaskliError):
|
|
34
|
+
"""Raised when a list file exists but cannot be parsed."""
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class OutdatedListFileError(TaskliError):
|
|
38
|
+
"""Raised when a list file uses an outdated schema version."""
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class InvalidListNameError(TaskliError):
|
|
42
|
+
"""Raised when a list name can't safely map to a file."""
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class ItemNotFoundError(TaskliError):
|
|
46
|
+
"""Raised when a task item id does not exist in a list."""
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class TooManyAncestorListsError(TaskliError):
|
|
50
|
+
"""Raised when a list name is nested more than 2 levels deep."""
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class UnknownConfigKeyError(TaskliError):
|
|
54
|
+
"""Raised when a config key does not exist."""
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class InvalidConfigValueError(TaskliError):
|
|
58
|
+
"""Raised when a config value fails validation."""
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class InvalidModifierValueError(TaskliError):
|
|
62
|
+
"""Raised when a settable modifier value fails its registry parse."""
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class InvalidReparentError(TaskliError):
|
|
66
|
+
"""Raised when re-nesting an item under itself or its own descendant."""
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class CorruptedConfigFileError(TaskliError):
|
|
70
|
+
"""Raised when the config file exists but cannot be parsed."""
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class OutdatedConfigFileError(TaskliError):
|
|
74
|
+
"""Raised when the config file uses an outdated schema version."""
|
taskli/hierarchy.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""List-name hierarchy helpers."""
|
|
2
|
+
|
|
3
|
+
__all__ = [
|
|
4
|
+
"parent_list_name",
|
|
5
|
+
"child_list_names",
|
|
6
|
+
"descendant_list_names",
|
|
7
|
+
"ancestor_chain",
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def parent_list_name(name: str) -> str | None:
|
|
12
|
+
"""Return the immediate parent list name, or None if top-level.
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
name : str
|
|
17
|
+
The list name.
|
|
18
|
+
|
|
19
|
+
Returns
|
|
20
|
+
-------
|
|
21
|
+
str | None
|
|
22
|
+
The text before the last '.', or None if `name` has no '.'.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
if "." not in name:
|
|
26
|
+
return None
|
|
27
|
+
|
|
28
|
+
return name.rsplit(".", 1)[0]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def child_list_names(name: str, all_names: list[str]) -> list[str]:
|
|
32
|
+
"""Return the immediate children of `name` from `all_names`.
|
|
33
|
+
|
|
34
|
+
Parameters
|
|
35
|
+
----------
|
|
36
|
+
name : str
|
|
37
|
+
The candidate parent list name.
|
|
38
|
+
all_names : list[str]
|
|
39
|
+
The full set of existing list names to search.
|
|
40
|
+
|
|
41
|
+
Returns
|
|
42
|
+
-------
|
|
43
|
+
list[str]
|
|
44
|
+
Names in `all_names` whose immediate parent is `name`, sorted.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
return sorted(n for n in all_names if parent_list_name(n) == name)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def descendant_list_names(name: str, all_names: list[str]) -> list[str]:
|
|
51
|
+
"""Return all descendants (any depth) of `name` from `all_names`.
|
|
52
|
+
|
|
53
|
+
Parameters
|
|
54
|
+
----------
|
|
55
|
+
name : str
|
|
56
|
+
The ancestor list name.
|
|
57
|
+
all_names : list[str]
|
|
58
|
+
The full set of existing list names to search.
|
|
59
|
+
|
|
60
|
+
Returns
|
|
61
|
+
-------
|
|
62
|
+
list[str]
|
|
63
|
+
Names in `all_names` nested under `name`, sorted.
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
prefix = f"{name}."
|
|
67
|
+
|
|
68
|
+
return sorted(n for n in all_names if n.startswith(prefix))
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def ancestor_chain(name: str) -> list[str]:
|
|
72
|
+
"""Return all ancestor names of `name`, nearest-root first.
|
|
73
|
+
|
|
74
|
+
Parameters
|
|
75
|
+
----------
|
|
76
|
+
name : str
|
|
77
|
+
The list name (may or may not exist).
|
|
78
|
+
|
|
79
|
+
Returns
|
|
80
|
+
-------
|
|
81
|
+
list[str]
|
|
82
|
+
E.g. for "a.b.c" returns ["a", "a.b"]. Empty if `name` has no
|
|
83
|
+
'.'.
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
segments = name.split(".")
|
|
87
|
+
|
|
88
|
+
return [".".join(segments[:i]) for i in range(1, len(segments))]
|