common-python-tasks 0.2.0__py3-none-any.whl → 0.3.1__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.
- common_python_tasks/__init__.py +2 -8
- common_python_tasks/__main__.py +23 -19
- common_python_tasks/data/generic/cliff.toml +5 -0
- common_python_tasks/docker.py +296 -233
- common_python_tasks/{compose.py → docker_compose.py} +15 -9
- common_python_tasks/env.py +41 -16
- common_python_tasks/git.py +97 -56
- common_python_tasks/github.py +59 -41
- common_python_tasks/project.py +67 -27
- common_python_tasks/tasks.py +157 -94
- common_python_tasks/utils.py +103 -18
- {common_python_tasks-0.2.0.dist-info → common_python_tasks-0.3.1.dist-info}/METADATA +10 -10
- {common_python_tasks-0.2.0.dist-info → common_python_tasks-0.3.1.dist-info}/RECORD +15 -14
- {common_python_tasks-0.2.0.dist-info → common_python_tasks-0.3.1.dist-info}/WHEEL +1 -1
- {common_python_tasks-0.2.0.dist-info → common_python_tasks-0.3.1.dist-info}/licenses/LICENSE +0 -0
common_python_tasks/__init__.py
CHANGED
|
@@ -9,8 +9,7 @@ __all__ = ["TaskCollection"]
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
def tasks(
|
|
12
|
-
include_tags: "Sequence[str] | None" = None,
|
|
13
|
-
exclude_tags: "Sequence[str]" = tuple(),
|
|
12
|
+
include_tags: "Sequence[str] | None" = None, exclude_tags: "Sequence[str]" = tuple()
|
|
14
13
|
) -> dict:
|
|
15
14
|
from .tasks import tasks as task_collection
|
|
16
15
|
|
|
@@ -19,9 +18,4 @@ def tasks(
|
|
|
19
18
|
elif include_tags is None:
|
|
20
19
|
include_tags = tuple()
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
globals()["tasks"] = _TASKS_ENTRYPOINT
|
|
24
|
-
return result
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
_TASKS_ENTRYPOINT = tasks
|
|
21
|
+
return task_collection(include_tags=include_tags, exclude_tags=exclude_tags)
|
common_python_tasks/__main__.py
CHANGED
|
@@ -13,7 +13,7 @@ def get_available_tasks(internal: bool = False) -> list[str]:
|
|
|
13
13
|
"""Return available task names for this package.
|
|
14
14
|
|
|
15
15
|
Args:
|
|
16
|
-
internal:
|
|
16
|
+
internal: If `True`, include internal task names starting with '_'.
|
|
17
17
|
|
|
18
18
|
Returns:
|
|
19
19
|
A list of task names.
|
|
@@ -39,7 +39,6 @@ def _extract_docstring_excerpt(doc: str) -> str:
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
def _get_task_docstring(task_name: str) -> str | None:
|
|
42
|
-
|
|
43
42
|
task_config = tasks()["tasks"].get(task_name)
|
|
44
43
|
if not isinstance(task_config, dict):
|
|
45
44
|
return None
|
|
@@ -50,11 +49,8 @@ def _get_task_docstring(task_name: str) -> str | None:
|
|
|
50
49
|
|
|
51
50
|
module_name, func_name = script.split(":", 1)
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
func = getattr(module, func_name)
|
|
56
|
-
except (ImportError, AttributeError):
|
|
57
|
-
return None
|
|
52
|
+
module = importlib.import_module(module_name)
|
|
53
|
+
func = getattr(module, func_name)
|
|
58
54
|
|
|
59
55
|
doc = inspect.getdoc(func)
|
|
60
56
|
if not doc:
|
|
@@ -63,17 +59,25 @@ def _get_task_docstring(task_name: str) -> str | None:
|
|
|
63
59
|
return _extract_docstring_excerpt(doc)
|
|
64
60
|
|
|
65
61
|
|
|
66
|
-
def
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
def get_task_tags(task_name: str) -> list[str] | None:
|
|
63
|
+
"""Return the tags associated with a task.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
task_name: The name of the task.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
A list of tags associated with the task, or `None` if no tags are found.
|
|
70
|
+
"""
|
|
71
|
+
tags = set()
|
|
72
|
+
for task in tasks:
|
|
73
|
+
if task.name != task_name:
|
|
74
|
+
continue
|
|
75
|
+
|
|
76
|
+
for tag in task.tags:
|
|
77
|
+
# `task-...` tags are internal synthetic tags auto-added by TaskCollection.
|
|
78
|
+
if not tag.startswith("task-"):
|
|
79
|
+
tags.add(tag)
|
|
70
80
|
|
|
71
|
-
tags = {
|
|
72
|
-
tag
|
|
73
|
-
for variant in task_variants
|
|
74
|
-
for tag in getattr(variant, "tags", ())
|
|
75
|
-
if isinstance(tag, str) and not tag.startswith("task-")
|
|
76
|
-
}
|
|
77
81
|
return sorted(tags) or None
|
|
78
82
|
|
|
79
83
|
|
|
@@ -81,8 +85,8 @@ def print_available_tasks(internal: bool = False, include_docs: bool = False) ->
|
|
|
81
85
|
"""Print available tasks.
|
|
82
86
|
|
|
83
87
|
Args:
|
|
84
|
-
internal:
|
|
85
|
-
include_docs:
|
|
88
|
+
internal: If `True`, include internal task names starting with '_'.
|
|
89
|
+
include_docs: If `True`, include task docstrings.
|
|
86
90
|
"""
|
|
87
91
|
print("\nAvailable tasks in this release:\n")
|
|
88
92
|
for task_name in get_available_tasks(internal=internal):
|