mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
refactor: 收口 V3 分层架构与插件兼容边界
This commit is contained in:
+25
-7
@@ -1,12 +1,30 @@
|
||||
from app.doctor.models import DoctorFinding, DoctorReport
|
||||
from app.doctor.runner import DoctorRunner
|
||||
"""MoviePilot 离线诊断公开门面,具体对象按需解析。"""
|
||||
|
||||
from importlib import import_module
|
||||
from typing import Any
|
||||
|
||||
|
||||
def run_doctor(*, fix: bool = False, deep: bool = False) -> DoctorReport:
|
||||
"""
|
||||
运行 MoviePilot 离线诊断并返回报告。
|
||||
"""
|
||||
return DoctorRunner(fix=fix, deep=deep).run()
|
||||
_EXPORT_MODULES = {
|
||||
"DoctorFinding": "app.doctor.models",
|
||||
"DoctorReport": "app.doctor.models",
|
||||
"DoctorRunner": "app.doctor.runner",
|
||||
"run_doctor": "app.doctor.runner",
|
||||
}
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""首次访问公开诊断对象时只加载其所属实现模块。"""
|
||||
module_name = _EXPORT_MODULES.get(name)
|
||||
if module_name is None:
|
||||
raise AttributeError(f"module 'app.doctor' has no attribute {name!r}")
|
||||
value = getattr(import_module(module_name), name)
|
||||
globals()[name] = value
|
||||
return value
|
||||
|
||||
|
||||
def __dir__() -> list[str]:
|
||||
"""让惰性公开对象继续支持交互式发现。"""
|
||||
return sorted(set(globals()) | set(_EXPORT_MODULES))
|
||||
|
||||
|
||||
__all__ = [
|
||||
|
||||
Reference in New Issue
Block a user