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:
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:
- Raises:
OSError – If the file does not meet the expected access
permissionor if it is a directory.ValueError – If the file does not have one of the expected
suffixesor if thepermissionargument is invalid.