filefisher.FileFinder.find_paths#
- FileFinder.find_paths(keys=None, *, on_parse_error='raise', on_empty='raise', **keys_kwargs)#
find files in the file system using the file and path (folder) pattern
- Parameters:
keys (dict) – Dictionary containing keys to create the search pattern. Several names can be passed for each key as list (interpreted as or). None is ignored.
on_parse_error (“raise” | “warn” | “skip”, default: “raise”) – What to do if a path/file name cannot be parsed. If “raise” raises a ValueError, if “warn” raises a warning and if “skip” ignores the file.
on_empty (“raise” | “warn” | “allow”, default: “raise”) – Behaviour when no files are found: “raise” (default) raises a ValueError, “warn” raises a warning. For “warn” and “allow” an empty FileContainer is returned.
**keys_kwargs ({key: indexer, …}, optional) – The keyword arguments form of
keys. When the same key is passed inkeysandkeys_kwargsthe latter takes priority.
Notes
Missing
keysare replaced with"*".Examples
>>> path_pattern = "/root/{category}" >>> file_pattern = "{category}_file_{number}" >>> ff = FileFinder(path_pattern, file_pattern)
>>> ff.find_paths() Looks for - "/root/*/"
>>> ff.find_paths(category="foo") Looks for - "/root/foo/"
>>> ff.find_paths(dict(category=["foo", "bar"])) Looks for - "/root/foo/" - "/root/bar/"