phys2cvr.utils.check_ext

phys2cvr.utils.check_ext(all_ext, fname, scan=False, remove=False)[source]

Check which extension a file has, and possibly remove it.

Parameters:
all_extlist

All possible extensions to check within.

fnamestr or os.PathLike

The filename to check.

scanbool, optional

Scan the given path to see if there is a file with that extension If True and no path declared, check if fname has a path, if not scan ‘.’ If False, don’t scan any folder.

removebool, optional

Remove the extension from fname if it has one.

Returns:
obj_returnUses a list to return variable amount of options.
has_extboolean

True if the extension is found, false otherwise.

fnamestr or os.PathLike

If remove is True, return (extensionless) fname.

extstr

If both remove and has_ext are True, returns also found extension.