# -*- coding: utf-8 -*- r"""观澜 · 数据接入管理 —— **对外公开面**(P0 阶段:接口先立,实现仍在既有路径)。 用户令 2026-09-22:按模块重构源代码目录,**每模块只许经 `api.py` 被别的模块调用**。 本文件当前把公开名**惰性转发**到既有实现(src/windscada/{data,scada_source,slim,mdb_names}.py + scripts/{rebuild_*,scada_*,raw_scan,raw_data_check,place_raw_data,pitch_face_build,baseline_38_build,component_history_build,csv_to_mdb}.py),因此: * 调用的行为与重构前完全一致(零行为变化); * 后续阶段(见 `docs/重构方案_模块化_v0.1.md`)把实现搬到本模块目录后,**只改这里的目标映射**, 调用方一行都不用动; * 惰性转发(PEP 562)保证 import 本文件不会连带 import 重依赖。 """ from __future__ import annotations import importlib # 模块(按名惰性转发)—— P2 起实现就在本模块目录内 _TARGETS: dict[str, str] = { 'data': 'app_ETL.app_ETL_guanlan.data', 'scada_source': 'app_ETL.app_ETL_guanlan.scada_source', 'slim': 'app_ETL.app_ETL_guanlan.slim', 'mdb_names': 'app_ETL.app_ETL_guanlan.mdb_names', } # ★2026-09-22 P3 增设: 常用的**函数级**公开名(算法层经本公开面取数,不再直接 import 本模块内部实现)。 # `from app_ETL.app_ETL_guanlan.api import load_10min` 这类写法由此成立。 from app_ETL.app_ETL_guanlan.data import contracted_cols, load_10min # noqa: E402,F401 from app_ETL.app_ETL_guanlan import slim # noqa: E402,F401 __all__ = list(_TARGETS) + ['load_10min', 'contracted_cols'] 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