chronaxis.sources
源码基线:8904c2f744951857659abd40aaa3535d57faf53c
1"""按需公开来源适配器和批次模型;读取 BLF 不加载无关的数组后端。23公开名称、类身份与原模块保持一致;只在访问相应名称时导入定义。4导入本包不打开输入、DBC 或工作目录,也不创建进程。5"""6from importlib import import_module78_EXPORTS = {9 'MemorySourceAdapter':'memory',10 'SignalCSVSourceAdapter':'signal_csv',11 'SignalCSVSpec':'csv_spec', 'CSVSourceRef':'csv_spec',12 **dict.fromkeys(('FieldDescription','FieldLocation','ReadRequest','SignalBatch','SignalSeries',13 'SourceCapabilities','SourceDescription'),'models'),14 **dict.fromkeys(('BatchValidator','SourceAdapter','SourceClosedError','SourceReadError'),'protocol'),15}16__all__ = ['MemorySourceAdapter','SignalCSVSpec','CSVSourceRef','SignalCSVSourceAdapter',17 'FieldDescription','FieldLocation','ReadRequest','SignalBatch','SignalSeries',18 'SourceCapabilities','SourceDescription','BatchValidator','SourceAdapter',19 'SourceClosedError','SourceReadError']202122def __getattr__(name: str) -> object:23 """按公开名称返回原对象;未知名称抛 AttributeError,不导入其他来源。"""24 module = _EXPORTS.get(name)25 if module is None:26 raise AttributeError(f'chronaxis.sources没有公开属性{name!r}')27 value = getattr(import_module('.'+module,__name__),name)28 globals()[name] = value29 return value30