Files
douyi_guaji_main/douyin/detection/detection_pkg/_common.py
T
CodexandClaude Opus 4.7 787c4e8eec 拆分 douyin_detection (1756 → 3 个子模块 + 22 行 shim)
把 douyin/detection/douyin_detection.py 按职责拆成
douyin/detection/detection_pkg/ 子包:

- _common (14)    _ensure_detection_cache 共享缓存初始化
- detail (323)    check_detail_height + check_in_fudai_detail(详情页相关)
- finder (1438)   check_have_fudai_with_ready_screenshot(找福袋图标主入口,最大头)

原文件改为 22 行 re-export shim,4 个公共符号全部保留。
- check_in_fudai_detail 5 处外部引用
- check_have_fudai_with_ready_screenshot 3 处外部引用
- check_detail_height 2 处外部引用
全部不需修改。

子包名 detection_pkg 是为了避免与同目录下的 shim 文件 douyin_detection.py
潜在的命名混淆。

回归:
- 4 个新文件 + shim compileall 通过
- pytest 353 passed / 1 skipped
- 旧 import 路径与新子包路径返回同一函数对象

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 16:55:24 +08:00

15 lines
441 B
Python

"""detection_pkg._common - 共享:分析器检测缓存初始化。"""
from __future__ import annotations
from typing import Any
def _ensure_detection_cache(analyser: Any) -> None:
"""Ensure analyser has a simple detection cache structure."""
if not hasattr(analyser, "_detection_cache"):
analyser._detection_cache = {}
if not hasattr(analyser, "_detection_cache_ttl"):
analyser._detection_cache_ttl = 2.0