Skip to content

climate_ref.datasets.utils #

validate_path(raw_path) #

Validate the prefix of a dataset against the data directory

Source code in packages/climate-ref/src/climate_ref/datasets/utils.py
def validate_path(raw_path: str) -> Path:
    """
    Validate the prefix of a dataset against the data directory
    """
    prefix = Path(raw_path)

    if not prefix.exists():
        raise FileNotFoundError(prefix)

    if not prefix.is_absolute():
        raise ValueError(f"Path {prefix} must be absolute")

    return prefix