refactor: 优化 CoreDriver 实现并增强代码可读性

- 优化 部分核心功能实现。
- 新增 详细的文档字符串(Docstrings)和注释。
- 移除 代码中的冗余注释和无效代码。
This commit is contained in:
2026-01-22 15:39:20 +08:00
parent 1bcad0d166
commit 2e98252e34
5 changed files with 266 additions and 87 deletions

20
utils/decorators.py Normal file
View File

@@ -0,0 +1,20 @@
import logging
from functools import wraps
from typing import Union, Callable
logger = logging.getLogger(__name__)
def resolve_wait_method(func):
"""
装饰器:将字符串形式的等待条件解析为可调用的 EC 对象
"""
@wraps(func)
def wrapper(self, method: Union[Callable, str], *args, **kwargs):
if isinstance(method, str):
# TODO: 这里可以接入 custom_ec 字典进行查找
# method = custom_ec.get(method, lambda x: False)
logger.info(f"解析命名等待条件: '{method}'")
# 保持原有逻辑作为占位
method = lambda _: False
return func(self, method, *args, **kwargs)
return wrapper