validate_filepath(fpath, file_extension, exception_type)[source]

Validate an input filepath.

The input is verified to be a string with a valid ending, and it is validated that the file exists on disk. If any of these conditions are not met, an exception is raised.

  • fpath (str) – Filepath to validate.

  • file_extension (str or iterable of str) – A single file extension or an iterable of acceptable file extensions for the input path.

  • exception_type (Exception) – A class indicating the type of exception to raise if file extension is incorrect.

  • TypeError – If the input fpath is not a string.

  • exception_type – If the input fpath does not end in a valid extension.

  • FileNotFoundError – If the input fpath does not exist on disk.