PathLike

This page documents checkers for arguments that represent filesystem paths.

class argscheck.pathlike.PathLike(*args, **kwargs)

Check if x is of a path-like type (str or pathlib.Path).

Additional checks and conversions can be performed by changing some of the default parameters.

Parameters
  • is_dirbool – If True, x must point to an existing directory.

  • is_filebool – If True, x must point to an existing file.

  • suffixOptional[str]x must have this suffix (wildcards and regex are not supported).

  • suffixesOptional[List[str]]x must have these suffixes (wildcards and regex are not supported). If both suffix and suffixes are provided, then, x’s suffix(es) must match at least one of them.

  • ignore_suffix_casebool – Whether the suffix’s case should be ignored. Only relevant if suffix or suffixes are provided.

  • as_strbool – If True, x will be converted to str before it is returned.

  • as_pathbool – If True, x will be converted to pathlib.Path before it is returned.

class argscheck.pathlike.ExistingDir(*args, **kwargs)

Same as PathLike, plus, x must point to an existing directory.

class argscheck.pathlike.ExistingFile(*args, **kwargs)

Same as PathLike, plus, x must point to an existing file.