in src/databao_context_engine/project/datasource_discovery.py [0:0]
def load_datasource_descriptor(path: Path) -> DatasourceDescriptor | None:
"""
Load a single file with src/<parent_name>/ into a DatasourceDescriptor
"""
if not path.is_file():
return None
parent_name = path.parent.name
extension = path.suffix.lower().lstrip(".")
if parent_name == "files":
return DatasourceDescriptor(path=path.resolve(), main_type=parent_name, kind=DatasourceKind.FILE)
if extension in {"yaml", "yml"}:
return DatasourceDescriptor(path=path.resolve(), main_type=parent_name, kind=DatasourceKind.CONFIG)
if extension:
return DatasourceDescriptor(path=path.resolve(), main_type=parent_name, kind=DatasourceKind.FILE)
logger.debug("Skipping file without extension: %s", path)
return None