library#

Functions to retrieve values from filename.

Functions

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.

Deprecated since version 1.3.0: You can now use finder.fix_by_filter(group, lambda x: min < x < 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.

Deprecated since version 1.3.0: You can now use finder.fix_by_filter("date", lambda x: start < x < stop)

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.

Matches that can be used are : YBmdjHMSFxX. If a matcher is not found in the filename, it will be replaced by the element of the default date argument. All values deduced from these matches will be compared. If different matchers give different values (for instance the group Y and F give a different year), an exception will be raised.

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

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

Return type:

datetime