INNER CODE UNIT · Python

_validate_name

faridrashidi/cnsplots · src/cnsplots/_cli.py:57

def _validate_name(name: str) -> None:
    if (
        not name
        or "\\" in name
        or ":" in name
        or any(part in ("", ".", "..", _MANIFEST) for part in name.split("/"))
    ):
        raise ValueError(f"unsafe managed file name: {name!r}")


def _checked_path(root: Path, name: str) -> Path:
    path = root
    for part in name.split("/"):
        if path.exists() and not path.is_dir():
            raise NotADirectoryError(f"not a skill directory: {path}")
        path = path / part
        if path.is_symlink():
            raise ValueError(f"refusing to follow skill symlink: {path}")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…