# -*- coding: utf-8 -*- r"""观澜 · 后端 —— **对外公开面**(P0 阶段:接口先立,实现仍在既有路径)。 用户令 2026-09-22:按模块重构源代码目录,**每模块只许经 `api.py` 被别的模块调用**。 本文件当前把公开名**惰性转发**到既有实现(guanlan.py、scripts/{windscada_serve,guanlan_gateway,guanlan_ops,_ops_*}.py、src/windscada/{config,i18n,report_export}.py(terms/lang 已在 P5 迁入 app_frontEnd)),因此: * 调用的行为与重构前完全一致(零行为变化); * 后续阶段(见 `docs/重构方案_模块化_v0.1.md`)把实现搬到本模块目录后,**只改这里的目标映射**, 调用方一行都不用动; * 惰性转发(PEP 562)保证 import 本文件不会连带 import 重依赖。 """ from __future__ import annotations import importlib # 公开名 → 现有实现(P0 转发目标;P1 起改为本模块内的实现模块) _TARGETS: dict[str, str] = { 'config': 'src.windscada.config', 'i18n': 'src.windscada.i18n', 'report_export': 'src.windscada.report_export', 'deid': 'src.windscada.deid', 'cms_serve': 'src.windcms.serve', 'cms_orchestrator': 'src.windcms.orchestrator', } __all__ = list(_TARGETS) def __getattr__(name: str): target = _TARGETS.get(name) if target is None: raise AttributeError( f'{__name__} 未公开 {name!r};公开面见 __all__ —— 模块间调用只许走 api.py' ) mod = importlib.import_module(target) globals()[name] = mod return mod