File size: 1,342 Bytes
7d23275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""Unified OpenEnv package bundling the CLI and core runtime."""

from __future__ import annotations

from importlib import import_module, metadata

__all__ = [
    "core",
    "cli",
    "AutoEnv",
    "AutoAction",
    "GenericEnvClient",
    "GenericAction",
    "SyncEnvClient",
]

try:
    __version__ = metadata.version("openenv")  # type: ignore[arg-type]
except metadata.PackageNotFoundError:  # pragma: no cover - local dev
    __version__ = "0.0.0"


_LAZY_MODULES = {
    "core": ".core",
    "cli": ".cli",
}

_LAZY_ATTRS = {
    "AutoEnv": (".auto", "AutoEnv"),
    "AutoAction": (".auto", "AutoAction"),
    "GenericEnvClient": (".core", "GenericEnvClient"),
    "GenericAction": (".core", "GenericAction"),
    "SyncEnvClient": (".core", "SyncEnvClient"),
}


def __getattr__(name: str):
    if name in _LAZY_MODULES:
        module = import_module(_LAZY_MODULES[name], __name__)
        globals()[name] = module
        return module

    if name in _LAZY_ATTRS:
        module_path, attr_name = _LAZY_ATTRS[name]
        module = import_module(module_path, __name__)
        value = getattr(module, attr_name)
        globals()[name] = value
        return value

    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")


def __dir__() -> list[str]:
    return sorted(set(globals().keys()) | set(__all__))