zut.path.normalize_path

zut.path.normalize_path(path: str | PathLike, dir: str | PathLike | None = None, *, mkparents=False, **kwargs) Path
zut.path.normalize_path(path: IO, dir: str | PathLike | None = None, *, mkparents=False, **kwargs) IO
zut.path.normalize_path(path: None, dir: str | PathLike | None = None, *, mkparents=False, **kwargs) None

Relativize a path from the current working directory if it is inside its tree.

Parameters:
  • path – The path to normalize.

  • dir – If given and path is a string not containing ‘/’ or ‘\’, consider path as a member of the dir directory.

  • mkparents – If True, create parent directories if they do not exist.