check_path¶
- tayph.check_path(filepath, varname='filepath in check_path()', exists=False)[source] [edit on github]¶
This is a short function that handles file paths when input to other functions. It checks that the proposed file path is either a string or a pathlib Path object, and converts to the latter if its a string. If the exists keyword is set to true, it will check that the path (either a file or a folder) exists, and raise an exception if it doesn’t. All your filepath needs wrapped up in one :)
This function tests the dimensions and shape of the input array var. Sizes is the number of elements on each axis.
- Parameters
- filepathstr, Path object
The path that needs to be vetted. This can be a folder or a filepath.
- varnamestr
Name or description of the variable to assist in debugging.
- existsbool
If set to True, the file/folder needs to exist in order to pass the test. If False, the routine only checks whether the variable provided is in fact a string or a path object.