Matches#
- class Matches(matches, groups)#
Bases:
objectScan an input file and store the results.
- Parameters:
- classmethod from_filename(filename, pattern, groups)#
Find matches for a given filename.
- Parameters:
- Returns:
matches – A
Matchesobject, or None if the filename did not match.- Raises:
IndexError – Not as many matches as groups. Maybe one of the group regex contains an additional (unwanted) capturing group ?
- Return type:
Matches | None
- get_date(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.
- get_matches(key, keep_discard=False)#
Get Match objects corresponding to key.
- get_value(key, parse=True, keep_discard=False)#
Get matched value corresponding to key.
Return a single value. If multiple groups correspond to
key, the value of the first one to appear in the pattern is returned.- Parameters:
- Raises:
KeyError – No group with no ‘discard’ option was found.
- Return type:
- get_values(key, parse=True, keep_discard=False)#
Get matched values corresponding to key.
Return a list of values, even if only one group is selected.