filefinder.library#
Functions to retrieve values from filename.
Functions
|
Filter filename using the value parsed for group. |
|
Filter filename to be between two dates. |
|
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:
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.
- 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.
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.