B x `5ã@s<dZddlZddlmZGdd„deƒZGdd„deƒZdS) z8 This module provides the base definition for patterns. éNé)Úunicodec@s$eZdZdZdZdd„Zdd„ZdS)ÚPatternzG The :class:`Pattern` class is the abstract definition of a pattern. )ÚincludecCs ||_dS)zâ Initializes the :class:`Pattern` instance. *include* (:class:`bool` or :data:`None`) is whether the matched files should be included (:data:`True`), excluded (:data:`False`), or is a null-operation (:data:`None`). N)r)Úselfr©rú4/tmp/pip-unpacked-wheel-y3tpd19o/pathspec/pattern.pyÚ__init__s zPattern.__init__cCstd |jj|jj¡ƒ‚dS)a3 Matches this pattern against the specified files. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains each file relative to the root directory (e.g., ``"relative/path/to/file"``). Returns an :class:`~collections.abc.Iterable` yielding each matched file path (:class:`str`). z{}.{} must override match().N)ÚNotImplementedErrorÚformatÚ __class__Ú __module__Ú__name__)rÚfilesrrrÚmatch#s z Pattern.matchN)rr Ú __qualname__Ú__doc__Ú __slots__r rrrrrr srcsBeZdZdZdZd ‡fdd„ Zdd„Zdd „Zed d „ƒZ ‡Z S) Ú RegexPatternza The :class:`RegexPattern` class is an implementation of a pattern using regular expressions. )ÚregexNcs°d|_t|ttfƒrN|dks,td ||¡ƒ‚| |¡\}}|dk r–t |¡}nH|dk rft |dƒrf|}n0|dkrˆ|dks–td ||¡ƒ‚nt d |¡ƒ‚t t |ƒ  |¡||_dS)a> Initializes the :class:`RegexPattern` instance. *pattern* (:class:`unicode`, :class:`bytes`, :class:`re.RegexObject`, or :data:`None`) is the pattern to compile into a regular expression. *include* (:class:`bool` or :data:`None`) must be :data:`None` unless *pattern* is a precompiled regular expression (:class:`re.RegexObject`) in which case it is whether matched files should be included (:data:`True`), excluded (:data:`False`), or is a null operation (:data:`None`). .. NOTE:: Subclasses do not need to support the *include* parameter. Nz8include:{!r} must be null when pattern:{!r} is a string.rz4include:{!r} must be null when pattern:{!r} is null.z3pattern:{!r} is not a string, RegexObject, or None.)rÚ isinstancerÚbytesÚAssertionErrorr Úpattern_to_regexÚreÚcompileÚhasattrÚ TypeErrorÚsuperrr )rÚpatternrr)r rrr 9s zRegexPattern.__init__cCs*t|tƒr"|j|jko |j|jkStSdS)z¯ Tests the equality of this regex pattern with *other* (:class:`RegexPattern`) by comparing their :attr:`~Pattern.include` and :attr:`~RegexPattern.regex` attributes. N)rrrrÚNotImplemented)rÚotherrrrÚ__eq__is zRegexPattern.__eq__ccs2|jdk r.x"|D]}|j |¡dk r|VqWdS)a/ Matches this pattern against the specified files. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains each file relative to the root directory (e.g., "relative/path/to/file"). Returns an :class:`~collections.abc.Iterable` yielding each matched file path (:class:`str`). N)rrr)rrÚpathrrrrts  zRegexPattern.matchcCs|dfS)a¼ Convert the pattern into an uncompiled regular expression. *pattern* (:class:`str`) is the pattern to convert into a regular expression. Returns the uncompiled regular expression (:class:`str` or :data:`None`), and whether matched files should be included (:data:`True`), excluded (:data:`False`), or is a null-operation (:data:`None`). .. NOTE:: The default implementation simply returns *pattern* and :data:`True`. Tr)ÚclsrrrrrƒszRegexPattern.pattern_to_regex)N) rr rrrr r"rÚ classmethodrÚ __classcell__rr)r rr0s 0 r)rrÚcompatrÚobjectrrrrrrÚs %