2025-12-16 23:23:43 -08:00
|
|
|
|
"""Tool helpers.
|
|
|
|
|
|
|
|
|
|
|
|
This package contains wrappers around external tools (e.g. yt-dlp) so cmdlets can share
|
|
|
|
|
|
common defaults (cookies, timeouts, format selectors) and users can override them via
|
|
|
|
|
|
`config.conf`.
|
|
|
|
|
|
"""
|
2026-05-03 17:29:32 -07:00
|
|
|
|
from __future__ import annotations
|
2025-12-16 23:23:43 -08:00
|
|
|
|
|
2026-05-03 17:29:32 -07:00
|
|
|
|
# Lazy-loaded to avoid pulling in yt_dlp, playwright, and their heavy transitive
|
|
|
|
|
|
# dependencies (~1–2 s) at package import time. Each submodule is loaded only when
|
|
|
|
|
|
# a name from it is first accessed through this package namespace.
|
2025-12-16 23:23:43 -08:00
|
|
|
|
|
2025-12-30 23:19:02 -08:00
|
|
|
|
__all__ = [
|
2026-05-03 17:29:32 -07:00
|
|
|
|
"YtDlpTool",
|
|
|
|
|
|
"YtDlpDefaults",
|
|
|
|
|
|
"PlaywrightTool",
|
|
|
|
|
|
"PlaywrightDefaults",
|
|
|
|
|
|
"FlorenceVisionTool",
|
|
|
|
|
|
"FlorenceVisionDefaults",
|
2025-12-30 23:19:02 -08:00
|
|
|
|
]
|
2026-05-03 17:29:32 -07:00
|
|
|
|
|
|
|
|
|
|
_MODULE_ATTRS = {
|
|
|
|
|
|
"YtDlpTool": ".ytdlp",
|
|
|
|
|
|
"YtDlpDefaults": ".ytdlp",
|
|
|
|
|
|
"PlaywrightTool": ".playwright",
|
|
|
|
|
|
"PlaywrightDefaults": ".playwright",
|
|
|
|
|
|
"FlorenceVisionTool": ".florencevision",
|
|
|
|
|
|
"FlorenceVisionDefaults": ".florencevision",
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __getattr__(name: str) -> object:
|
|
|
|
|
|
submod = _MODULE_ATTRS.get(name)
|
|
|
|
|
|
if submod is None:
|
|
|
|
|
|
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
|
|
|
|
from importlib import import_module
|
|
|
|
|
|
mod = import_module(submod, package=__name__)
|
|
|
|
|
|
obj = getattr(mod, name)
|
|
|
|
|
|
# Cache on this module so subsequent accesses bypass __getattr__.
|
|
|
|
|
|
globals()[name] = obj
|
|
|
|
|
|
return obj
|
|
|
|
|
|
|