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_ext
list All possible extensions to check within.
- fname
stroros.PathLike The filename to check.
- scan
bool, 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.
- remove
bool, optional Remove the extension from fname if it has one.
- all_ext
- Returns:
- obj_return
Usesalisttoreturnvariableamountof options. - has_extboolean
True if the extension is found, false otherwise.
- fnamestr or os.PathLike
If
removeis True, return (extensionless) fname.- extstr
If both
removeandhas_extare True, returns also found extension.
- obj_return