Part of bzrlib.globbing View In Hierarchy
Known subclasses: bzrlib.globbing._OrderedGlobster
Provides the capability to search the patterns to find a match for a given filename (including the full path).
Patterns are translated to regular expressions to expidite matching.
The regular expressions for multiple patterns are aggregated into a super-regex containing groups of up to 99 patterns. The 99 limitation is due to the grouping limit of the Python re module. The resulting super-regex and associated patterns are stored as a list of (regex,[patterns]) in _regex_patterns.
For performance reasons the patterns are categorised as extension patterns (those that match against a file extension), basename patterns (those that match against the basename of the filename), and fullpath patterns (those that match against the full path). The translations used for extensions and basenames are relatively simpler and therefore faster to perform than the fullpath patterns.
Also, the extension patterns are more likely to find a match and so are matched first, then the basename patterns, then the fullpath patterns.
Method | __init__ | Undocumented |
Method | match | Searches for a pattern that matches the given filename. |
Static Method | identify | Returns pattern category. |
Static Method | is_pattern_valid | Returns True if pattern is valid. |
Method | _add_patterns | Undocumented |
:return A matching pattern or None if there is no matching pattern.