filefisher.FileFinder

filefisher.FileFinder#

class filefisher.FileFinder(path_pattern, file_pattern, *, test_paths=None)#
__init__(path_pattern, file_pattern, *, test_paths=None)#

find and create file names based on python format syntax

Parameters:
  • path_pattern (str) – String denoting the path (folder) pattern where everything variable is enclosed in curly braces.

  • file_pattern (str) – String denoting the file pattern where everything variable is enclosed in curly braces.

  • test_paths (list of str, default None) – A list of paths to use instead of querying the file system. To be used for testing and demonstration.

Examples

>>> path_pattern = "/root/{category}"
>>> file_pattern = "{category}_file_{number}"
>>> ff = FileFinder(path_pattern, file_pattern)

Methods

__init__(path_pattern, file_pattern, *[, ...])

find and create file names based on python format syntax

create_file_name([keys])

build file name from keys

create_full_name([keys])

build full (folder + file) name from keys

create_path_name([keys])

build path (folder) name from keys

find_files([keys, on_parse_error, on_empty])

find files in the file system using the file pattern

find_paths([keys, on_parse_error, on_empty])

find files in the file system using the file and path (folder) pattern

find_single_file([keys])

find exactly one file in the file system using the file and path pattern

find_single_path([keys])

find exactly one path in the file system using the path pattern