daedalus-tools 0.13.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.
- daedalus/__init__.py +52 -0
- daedalus/__main__.py +9 -0
- daedalus/_library/bash/daedalus_common.sh +35 -0
- daedalus/_library/bash/hello_bash.sh +27 -0
- daedalus/_library/batch/README.md +6 -0
- daedalus/_library/powershell/README.md +6 -0
- daedalus/_library/python/src/gpgtools/gpgtools.py +1249 -0
- daedalus/_library/python/src/gpgtools/spec.md +375 -0
- daedalus/_library/python/src/hello/hello.py +51 -0
- daedalus/_library/python/src/hello/spec.md +33 -0
- daedalus/_library/python/src/init/init.py +122 -0
- daedalus/_library/python/src/init/spec.md +92 -0
- daedalus/_library/python/src/publish/publish.py +208 -0
- daedalus/_library/python/src/publish/spec.md +119 -0
- daedalus/cli.py +229 -0
- daedalus/completions.py +140 -0
- daedalus/daedalus_logging/__init__.py +91 -0
- daedalus/gpgtools/gpgtools.py +1249 -0
- daedalus/gpgtools/spec.md +375 -0
- daedalus/hello/hello.py +51 -0
- daedalus/hello/spec.md +33 -0
- daedalus/init/init.py +122 -0
- daedalus/init/spec.md +92 -0
- daedalus/publish/publish.py +208 -0
- daedalus/publish/spec.md +119 -0
- daedalus/registry.py +103 -0
- daedalus/run_python_script.py +62 -0
- daedalus/runners.py +121 -0
- daedalus_tools-0.13.0.dist-info/METADATA +251 -0
- daedalus_tools-0.13.0.dist-info/RECORD +33 -0
- daedalus_tools-0.13.0.dist-info/WHEEL +5 -0
- daedalus_tools-0.13.0.dist-info/entry_points.txt +2 -0
- daedalus_tools-0.13.0.dist-info/top_level.txt +1 -0
daedalus/__init__.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""daedalus: run any registered script with ``daedalus <name> [args...]``.
|
|
2
|
+
|
|
3
|
+
CLI package; see SPEC.md. On import this module also registers every
|
|
4
|
+
``python/src/<folder>`` as a ``daedalus.<folder>`` package so library
|
|
5
|
+
scripts can import shared code in checkout and install alike
|
|
6
|
+
(SPEC.md section 10).
|
|
7
|
+
"""
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import pathlib
|
|
11
|
+
import sys
|
|
12
|
+
import types
|
|
13
|
+
|
|
14
|
+
PACKAGE_DIR = pathlib.Path(__file__).resolve().parent
|
|
15
|
+
REPO_ROOT = PACKAGE_DIR.parent
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def library_root(package_dir: pathlib.Path = PACKAGE_DIR) -> pathlib.Path:
|
|
19
|
+
"""Bundled _library of an installed wheel, else the checkout root."""
|
|
20
|
+
installed = package_dir / "_library"
|
|
21
|
+
return installed if installed.is_dir() else package_dir.parent
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
LIBRARY_ROOT = library_root()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def register_source_folders(repo_root: pathlib.Path = REPO_ROOT) -> list[str]:
|
|
28
|
+
"""Register python/src subfolders as daedalus.<folder> packages (SPEC item 10.3).
|
|
29
|
+
|
|
30
|
+
Each subfolder becomes an empty package whose search path is that
|
|
31
|
+
folder, unless a module of that name is already loaded. Returns the
|
|
32
|
+
names registered, in order.
|
|
33
|
+
"""
|
|
34
|
+
source = repo_root / "python" / "src"
|
|
35
|
+
if not source.is_dir():
|
|
36
|
+
return []
|
|
37
|
+
registered: list[str] = []
|
|
38
|
+
for folder in sorted(source.iterdir()):
|
|
39
|
+
if not folder.is_dir() or folder.name.startswith((".", "_")):
|
|
40
|
+
continue # not a library script package (e.g. __pycache__)
|
|
41
|
+
name = f"daedalus.{folder.name}"
|
|
42
|
+
if name in sys.modules:
|
|
43
|
+
continue
|
|
44
|
+
module = types.ModuleType(name)
|
|
45
|
+
module.__path__ = [str(folder)]
|
|
46
|
+
module.__package__ = name
|
|
47
|
+
sys.modules[name] = module
|
|
48
|
+
registered.append(name)
|
|
49
|
+
return registered
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
register_source_folders(REPO_ROOT)
|
daedalus/__main__.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Shared interface for daedalus bash scripts (SPEC.md item 6.10).
|
|
3
|
+
#
|
|
4
|
+
# A registered bash script sources this sibling file once and ends with:
|
|
5
|
+
# daedalus_bash_dispatch "$@"
|
|
6
|
+
# The script defines help() (its usage text) and main() (its body).
|
|
7
|
+
# daedalus completes the help words for the script (SPEC item 3.13.5.2);
|
|
8
|
+
# this helper runs them: help, -h, and --help print help(), everything
|
|
9
|
+
# else goes to main() with the arguments unchanged.
|
|
10
|
+
|
|
11
|
+
help() {
|
|
12
|
+
echo "bash script error: help() is not defined (SPEC item 6.10.2)" >&2
|
|
13
|
+
return 2
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
main() {
|
|
17
|
+
echo "bash script error: main() is not defined (SPEC item 6.10.3)" >&2
|
|
18
|
+
return 2
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
daedalus_is_help_request() {
|
|
22
|
+
case "${1-}" in
|
|
23
|
+
help|-h|--help) return 0 ;;
|
|
24
|
+
*) return 1 ;;
|
|
25
|
+
esac
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
daedalus_bash_dispatch() {
|
|
29
|
+
if daedalus_is_help_request "${1:-}"; then
|
|
30
|
+
help
|
|
31
|
+
local status=$?
|
|
32
|
+
exit "$status"
|
|
33
|
+
fi
|
|
34
|
+
main "$@"
|
|
35
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# hello_bash: sample bash script for the shared interface (SPEC item 6.10).
|
|
3
|
+
#
|
|
4
|
+
# Run via daedalus: daedalus hello_bash [name...]
|
|
5
|
+
# It exists to exercise help() routing, main() dispatch, and the
|
|
6
|
+
# completion of the help words (SPEC item 3.13.5.2) end to end.
|
|
7
|
+
# shellcheck source=/dev/null
|
|
8
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/daedalus_common.sh"
|
|
9
|
+
|
|
10
|
+
help() {
|
|
11
|
+
cat <<'EOF'
|
|
12
|
+
usage: hello_bash [name...]
|
|
13
|
+
|
|
14
|
+
Prints a hello line, once per name, default "world".
|
|
15
|
+
EOF
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
main() {
|
|
19
|
+
local names=("$@")
|
|
20
|
+
((${#names[@]})) || names=("world")
|
|
21
|
+
local name
|
|
22
|
+
for name in "${names[@]}"; do
|
|
23
|
+
echo "hello, ${name} (from daedalus bash)"
|
|
24
|
+
done
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
daedalus_bash_dispatch "$@"
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Batch scripts live here
|
|
2
|
+
|
|
3
|
+
`daedalus` runs every `*.bat` in this folder (SPEC.md section 9.2);
|
|
4
|
+
registered scripts are installed under `daedalus/_library/batch/`.
|
|
5
|
+
This README keeps the folder in git and in the sdist so the
|
|
6
|
+
sdist can rebuild its wheel (SPEC item 9.2.1).
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Powershell scripts live here
|
|
2
|
+
|
|
3
|
+
`daedalus` runs every `*.ps1` in this folder (SPEC.md section 9.2);
|
|
4
|
+
registered scripts are installed under `daedalus/_library/powershell/`.
|
|
5
|
+
This README keeps the folder in git and in the sdist so the
|
|
6
|
+
sdist can rebuild its wheel (SPEC item 9.2.1).
|