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:
TypeError – min and max cannot be both None.
- Return type:
- 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:
start (date | str) – Start and stop dates that define the range of dates to keep. Can each be a
datetime.dateordatetime.datetimeobject; or a string in which case a datetime object is created withfromisoformat().stop (date | str) – Start and stop dates that define the range of dates to keep. Can each be a
datetime.dateordatetime.datetimeobject; or a string in which case a datetime object is created withfromisoformat().default_date (dict | None) – Is passed to
get_date().finder (Finder)
filename (str)
matches (Matches)
- Returns:
keep – True if the file is within the range and must be kept. False otherwise.
- Return type:
- 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.