b.g.Globster(object) : class documentation

Part of bzrlib.globbing View In Hierarchy

Known subclasses: bzrlib.globbing._OrderedGlobster

A simple wrapper for a set of glob patterns.

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
def __init__(self, patterns):
Undocumented
def _add_patterns(self, patterns, translator, prefix=''):
Undocumented
def match(self, filename):
Searches for a pattern that matches the given filename.

:return A matching pattern or None if there is no matching pattern.

@staticmethod
def identify(pattern):
Returns pattern category.

:param pattern: normalized pattern.
Identify if a pattern is fullpath, basename or extension
and returns the appropriate type.
@staticmethod
def is_pattern_valid(pattern):
Returns True if pattern is valid.

:param pattern: Normalized pattern.
is_pattern_valid() assumes pattern to be normalized.
see: globbing.normalize_pattern
API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.