25 lines
586 B
Python
25 lines
586 B
Python
import importlib
|
|
from enum import StrEnum
|
|
from types import ModuleType
|
|
|
|
|
|
class Domain(StrEnum):
|
|
CACU = "cacu"
|
|
CAMA = "cama"
|
|
TEA = "tea"
|
|
|
|
|
|
def part(domain: Domain, name: str = "") -> ModuleType | None:
|
|
path = f"core.{domain.value}" + (f".{name}" if name else "")
|
|
try:
|
|
return importlib.import_module(path)
|
|
except ModuleNotFoundError as e:
|
|
if e.name is not None and path.startswith(e.name):
|
|
return None
|
|
raise
|
|
|
|
|
|
def measures(domain: Domain) -> dict:
|
|
found = part(domain, "measures")
|
|
return found.MEASURES if found else {}
|