filefinder.library#

Functions to retrieve values from filename.

Functions

filter_by_range(finder, filename, matches, group)

Filter filename using the value parsed for group.

filter_date_range(finder, filename, matches, ...)

Filter filename to be between two dates.

get_date(matches[, default_date])

Retrieve date from matched elements.

filter_by_range(finder, filename, matches, group, min=None, max=None)#

Filter filename using the value parsed for group.

Keep filename for which the value parsed for group fall within a specific range defined by min and max.

Parameters:
  • group (str) – Name of the group to use the parsed value. The first non-discard group of that name will be used.

  • min (float | None) – If not None, the parsed value must be above this.

  • max (float | None) – If not None, the parsed value mest be below this.

  • finder (Finder) –

  • filename (str) –

  • matches (Matches) –

Raises:

TypeErrormin and max cannot be both None.

Return type:

bool

filter_date_range(finder, filename, matches, start, stop, default_date=None)#

Filter filename to be between two dates.

Parameters:
Returns:

keep – True if the file is within the range and must be kept. False otherwise.

Return type:

bool

get_date(matches, default_date=None)#

Retrieve date from matched elements.

If a matcher is not found in the filename, it will be replaced by the element of the default date argument. Matchers that can be used are (in order of increasing priority): YBmdjHMSFxX. If two matchers have the same name, the last one in the pre-regex will get priority.

Parameters:
  • matches (Matches) – Matches obtained from a filename.

  • default_date (dict | None) – Default date. Dictionnary with keys: year, month, day, hour, minute, and second. Defaults to 1970-01-01 00:00:00

Return type:

datetime