devstuff 1.13.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.
- dev_setup/__init__.py +6 -0
- dev_setup/__main__.py +9 -0
- dev_setup/base.py +74 -0
- dev_setup/catalog.py +188 -0
- dev_setup/cli.py +49 -0
- dev_setup/commands/__init__.py +0 -0
- dev_setup/commands/add_cmd.py +334 -0
- dev_setup/commands/catalog_cmd.py +37 -0
- dev_setup/commands/delete_cmd.py +36 -0
- dev_setup/commands/docs_cmd.py +34 -0
- dev_setup/commands/functions_cmd.py +87 -0
- dev_setup/commands/help_cmd.py +59 -0
- dev_setup/commands/install_cmd.py +129 -0
- dev_setup/commands/list_cmd.py +76 -0
- dev_setup/commands/remove_cmd.py +53 -0
- dev_setup/commands/run_cmd.py +66 -0
- dev_setup/commands/update_cmd.py +149 -0
- dev_setup/function_runner.py +133 -0
- dev_setup/functions.schema.json +106 -0
- dev_setup/functions.yaml +111 -0
- dev_setup/functions_catalog.py +217 -0
- dev_setup/functions_registry.py +149 -0
- dev_setup/generic.py +719 -0
- dev_setup/registry.py +97 -0
- dev_setup/tools.yaml +679 -0
- dev_setup/ui.py +111 -0
- devstuff-1.13.1.dist-info/METADATA +617 -0
- devstuff-1.13.1.dist-info/RECORD +30 -0
- devstuff-1.13.1.dist-info/WHEEL +4 -0
- devstuff-1.13.1.dist-info/entry_points.txt +3 -0
dev_setup/registry.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dev_setup import catalog
|
|
4
|
+
from dev_setup.base import Tool
|
|
5
|
+
from dev_setup.generic import GenericTool
|
|
6
|
+
|
|
7
|
+
_registry: dict[str, Tool] = {}
|
|
8
|
+
_order: list[str] = []
|
|
9
|
+
_initialized = False
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _register(tool: Tool) -> None:
|
|
13
|
+
if tool.key not in _registry:
|
|
14
|
+
_registry[tool.key] = tool
|
|
15
|
+
_order.append(tool.key)
|
|
16
|
+
else:
|
|
17
|
+
_registry[tool.key] = tool
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _load_builtins() -> None:
|
|
21
|
+
effective, bundled, user = catalog.load_effective_catalog()
|
|
22
|
+
for key, data in effective.items():
|
|
23
|
+
tool = GenericTool.from_dict(data, key=key)
|
|
24
|
+
tool.builtin = key in bundled and key not in user
|
|
25
|
+
_register(tool)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def init() -> None:
|
|
29
|
+
global _initialized
|
|
30
|
+
if _initialized:
|
|
31
|
+
return
|
|
32
|
+
_initialized = True
|
|
33
|
+
_load_builtins()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def reload() -> None:
|
|
37
|
+
global _initialized
|
|
38
|
+
_registry.clear()
|
|
39
|
+
_order.clear()
|
|
40
|
+
_initialized = False
|
|
41
|
+
init()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def get(key: str) -> Tool | None:
|
|
45
|
+
init()
|
|
46
|
+
return _registry.get(key)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def all_tools() -> list[Tool]:
|
|
50
|
+
init()
|
|
51
|
+
return [_registry[k] for k in _order if k in _registry]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def exists(key: str) -> bool:
|
|
55
|
+
init()
|
|
56
|
+
return key in _registry
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def register(tool: Tool) -> None:
|
|
60
|
+
"""Register (or replace) a tool in the live registry."""
|
|
61
|
+
init()
|
|
62
|
+
_register(tool)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def deregister(key: str) -> None:
|
|
66
|
+
"""Remove a tool from the live registry by key."""
|
|
67
|
+
init()
|
|
68
|
+
_registry.pop(key, None)
|
|
69
|
+
if key in _order:
|
|
70
|
+
_order.remove(key)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def missing_requires(tool: Tool) -> list:
|
|
74
|
+
"""Return keys in the transitive requires closure that are not installed.
|
|
75
|
+
|
|
76
|
+
Walks requires recursively (depth-first) with cycle protection, so a
|
|
77
|
+
dependency's own missing dependencies are surfaced too. Order is
|
|
78
|
+
deterministic: deepest dependencies first.
|
|
79
|
+
"""
|
|
80
|
+
init()
|
|
81
|
+
missing: list[str] = []
|
|
82
|
+
seen: set = {tool.key}
|
|
83
|
+
|
|
84
|
+
def visit(key: str) -> None:
|
|
85
|
+
if key in seen:
|
|
86
|
+
return
|
|
87
|
+
seen.add(key)
|
|
88
|
+
dep = _registry.get(key)
|
|
89
|
+
if dep is not None:
|
|
90
|
+
for sub in dep.requires:
|
|
91
|
+
visit(sub)
|
|
92
|
+
if dep is None or not dep.is_installed():
|
|
93
|
+
missing.append(key)
|
|
94
|
+
|
|
95
|
+
for key in tool.requires:
|
|
96
|
+
visit(key)
|
|
97
|
+
return missing
|