crops.iomod package

Input/output functions.

check_path(path, typeofpath=None)[source]

Return full path if correct.

Parameters:
  • path (str) – Path to file or directory.
  • typeofpath (str, optional) – The type of path, ‘dir’ or ‘file’. All types are considered if not value is given, defaults to None.
Raises:
  • ValueError – If given typeofpath is neither ‘dir’ nor ‘file’.
  • argparse – If given path is not found.
Returns:

Absolute path.

Return type:

str

outpathgen(globaldir, subdir=None, filename=None, mksubdir=False)[source]

Build a filepath in an existing directory and create subdirectory if requested.

Parameters:
  • globaldir (str) – General output dir.
  • subdir (str, optional) – Additional subdirectory, defaults to None.
  • filename (str, optional.) – File name, defaults to None.
  • mksubdir (bool, optional) – Create directory if it does not exist, defaults to False.
Raises:

FileNotFoundError – If directory does not exist and mksubdir is False.

Returns:

Output filepath.

Return type:

str