# -*- coding: utf-8 -*- r"""观澜 · 公共层 —— **对外公开面**(P0 阶段:接口先立,实现仍在既有路径)。 用户令 2026-09-22:按模块重构源代码目录,**每模块只许经 `api.py` 被别的模块调用**。 本文件当前把公开名**惰性转发**到既有实现(src/{paths,version,logfile,proc,entry_refs,console,opsjob,derived_manifest,tabfmt}.py),因此: * 调用的行为与重构前完全一致(零行为变化); * 后续阶段(见 `docs/重构方案_模块化_v0.1.md`)把实现搬到本模块目录后,**只改这里的目标映射**, 调用方一行都不用动; * 惰性转发(PEP 562)保证 import 本文件不会连带 import 重依赖。 """ from __future__ import annotations import importlib from app_common.app_common_guanlan._root import install_root # noqa: F401 公开面之一 from app_common.app_common_guanlan._alias import alias_prefix # noqa: F401 旧前缀别名(过渡期) # 公开名 → 实现(P1 起实现就在本模块目录内;P2 起其他模块的构建器经本公开面取安装根) _TARGETS: dict[str, str] = { 'paths': 'app_common.app_common_guanlan.paths', 'version': 'app_common.app_common_guanlan.version', 'logfile': 'app_common.app_common_guanlan.logfile', 'proc': 'app_common.app_common_guanlan.proc', 'entry_refs': 'app_common.app_common_guanlan.entry_refs', 'console': 'app_common.app_common_guanlan.console', 'opsjob': 'app_common.app_common_guanlan.opsjob', 'derived_manifest': 'app_common.app_common_guanlan.derived_manifest', 'tabfmt': 'app_common.app_common_guanlan.tabfmt', } __all__ = list(_TARGETS) + ['install_root', 'alias_prefix'] 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