diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-09 18:14:32 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-09 18:14:32 +0100 |
| commit | 9047e5420a59b43ef35ae95abb8264768761fcab (patch) | |
| tree | d6e30a2d94feb9ac4acc6e0ee79de9032867b417 /deckit/modules/__init__.py | |
| parent | 1cd822b825145d921d678c27b0600c78e576826b (diff) | |
| download | deck-it-9047e5420a59b43ef35ae95abb8264768761fcab.tar.gz deck-it-9047e5420a59b43ef35ae95abb8264768761fcab.zip | |
feat: stats module
Diffstat (limited to 'deckit/modules/__init__.py')
| -rw-r--r-- | deckit/modules/__init__.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/deckit/modules/__init__.py b/deckit/modules/__init__.py new file mode 100644 index 0000000..76fc9c5 --- /dev/null +++ b/deckit/modules/__init__.py @@ -0,0 +1,26 @@ +"""Module discovery. + +Every `deckit/modules/<name>.py` exporting `make(cfg) -> Module` is a module. +Discovery is lazy and file-based, so a new module is a new file: nothing here +lists the modules, and a not-yet-written one simply stays absent. +""" + +import importlib +from pathlib import Path + +from ..module import Registry + + +def build(cfg: dict) -> Registry: + enabled = cfg.get("modules", {}) + modules = [] + for path in sorted(Path(__file__).parent.glob("*.py")): + name = path.stem + if name == "__init__" or not enabled.get(name, True): + continue + try: + mod = importlib.import_module(f"{__name__}.{name}") + except ImportError: + continue + modules.append(mod.make(cfg)) + return Registry(modules) |
