Files
douyi_guaji_main/gui/web_gui_pkg/__init__.py
T
CodexandClaude Opus 4.7 a6bbdcc400 拆分 web_gui (2251 → 5 子模块 + 2148 行原文件保留 ProcRunner/Handler/main)
把 gui/web_gui.py 中 11 个独立 helper 拆出到 gui/web_gui_pkg/ 子包,
ProcRunner 巨型类(1514 行 / 25 实例方法 / 390 处 self)+ Handler 类
(588 行)+ main 留在原文件。

新建子包:
- logger (29)         _wg_log + module logger
- ansi (17)           strip_ansi_escape_codes + _ANSI_ESCAPE_RE
- adb_compat (44)     5 个 thin wrapper(forward 到 gui.gui_core_pkg)
- nested (18)         get_nested_value(点号路径配置读取)
- stats_helpers (71)  _parse_countdown_seconds / _bucket / _inc_map(ProcRunner 3 个 @staticmethod)

策略:8 个顶层 helper 直接搬子包;ProcRunner 内 3 个 @staticmethod 也搬,
类内改成 1 行 @staticmethod forwarding 保持 ProcRunner._parse_countdown_seconds
等调用兼容。原文件 import gui.web_gui_pkg 暴露 11 个公共符号。

外部 import 路径全部不变:
- find_adb_executable / read_config / list_adb_devices 等共 70+ 处外部引用
  全部不需修改(CONFIG_PATH 17 处 / read_config 17 处 / find_adb_executable
  18 处 / list_adb_devices 21 处 / write_config 10 处 / 其他 1-7 处)

回归:
- 6 个新文件 + 改写后 web_gui.py compileall 通过
- pytest 353 passed / 1 skipped
- _wg_log / strip_ansi_escape_codes / get_nested_value 调用结果正确
- ProcRunner._parse_countdown_seconds('1:30') = 90 (薄壳 forwarding OK)
- ProcRunner._bucket(15, [0,10,50,100]) = '10-50'
- ProcRunner._inc_map(m, 'k', 5) -> {'k': 5}
- ProcRunner() 实例化 OK

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 18:57:52 +08:00

44 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""web_gui_pkg - gui/web_gui.py 的顶层 helper 子包。
原 gui/web_gui.py 拆出 11 个独立顶层 helper(8 个顶层函数 + 3 个 ProcRunner
@staticmethod),ProcRunner 巨型类(1514 行)/ Handler 类(588 行)/ main
留在原文件。
- logger _wg_log + module logger
- ansi strip_ansi_escape_codes
- adb_compat 5 个 thin wrapper(→ gui.gui_core_pkg)
- nested get_nested_value
- stats_helpers _parse_countdown_seconds / _bucket / _inc_map
"""
from .logger import _LOGGER, _wg_log
from .ansi import strip_ansi_escape_codes
from .adb_compat import (
find_adb_executable,
list_adb_devices,
read_config,
resolve_adb_device,
write_config,
)
from .nested import get_nested_value
from .stats_helpers import (
_bucket,
_inc_map,
_parse_countdown_seconds,
)
__all__ = [
"_wg_log",
"_LOGGER",
"strip_ansi_escape_codes",
"find_adb_executable",
"list_adb_devices",
"resolve_adb_device",
"read_config",
"write_config",
"get_nested_value",
"_parse_countdown_seconds",
"_bucket",
"_inc_map",
]