"""数据源注册表(可插拔入口)。 config.yaml 的 ``sources: [google_trends, pinterest]`` 决定启用哪些。 新增数据源:实现 graph/sources/base.DataSource,在此登记即可。 """ from typing import Dict from .base import DataSource from .google_trends_source import GoogleTrendsSource from .pinterest_source import PinterestSource SOURCES: Dict[str, type] = { "google_trends": GoogleTrendsSource, "pinterest": PinterestSource, } def get_source(name: str) -> DataSource: cls = SOURCES.get(name) if cls is None: raise ValueError(f"未知数据源: {name},可用: {list(SOURCES)}") return cls()