validate_file_path#

movement.validators.files.validate_file_path(file, *, permission='r', suffixes=None)[source]#

Validate the file has the expected permission(s) and suffix(es).

Parameters:
  • file (Path | str) – Path to the file to validate.

  • permission (Literal['r', 'w', 'rw']) – Expected access permission(s) for the file. If “r”, the file is expected to be readable. If “w”, the file is expected to be writable. If “rw”, the file is expected to be both readable and writable. Default is “r”.

  • suffixes (set[str] | None) – Expected suffix(es) for the file. If None (default), this check is skipped.

Returns:

The validated file path.

Return type:

Path

Raises:
  • OSError – If the file does not meet the expected access permission or if it is a directory.

  • ValueError – If the file does not have one of the expected suffixes or if the permission argument is invalid.