K i~dZddlZddlZddlZddlmZmZmZmZm Z m Z m Z mZmZGddeZ Gdde Zej$Gdd eZy) z8 This module provides the base definition for patterns. N) AnyAnyStrIterableIteratorMatchOptionalPatternTupleUnionc\eZdZdZdZdeeddfdZdee de e fdZ d e dee fd Z y) r zG The :class:`Pattern` class is the abstract definition of a pattern. includerreturnNc||_y)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`). Nr )selfrs V/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pathspec/pattern.py__init__zPattern.__init__s$,filesc#Ktjdj|jtd|D]}|j ||yw)a DEPRECATED: This method is no longer used and has been replaced by :meth:`.match_file`. Use the :meth:`.match_file` method with a loop for similar results. 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{cls.__module__}.{cls.__qualname__}.match() is deprecated. Use {cls.__module__}.{cls.__qualname__}.match_file() with a loop for similar results.cls) stacklevelN)warningswarnformat __class__DeprecationWarning match_file)rrfiles rmatchz Pattern.match.sV -- Ft~~F 2q B d ood' Js A AAr!cLtdj|j)z Matches this pattern against the specified file. *file* (:class:`str`) is the normalized file path to match against. Returns the match result if *file* matched; otherwise, :data:`None`. z?{cls.__module__}.{cls.__qualname__} must override match_file().r)NotImplementedErrorrr)rr!s rr zPattern.match_fileFs$ D Ft~~F  r)__name__ __module__ __qualname____doc__ __slots__rboolrrstrrr"rr rrr r sW Xd^  (3-0  C  HSM  rr ceZdZdZdZ ddeeedfdee ddffd Z ddde fd Z d e ded fd Z ede dee e ffd ZxZS) RegexPatternza The :class:`RegexPattern` class is an implementation of a pattern using regular expressions. )patternregexNr/rrcRt|ttfr<|Jd|d|d|j|\}}|Ht j |}n2|t |dr|}n!||Jd|d|dtd|dtt|+|||_ |_ y) a( Initializes the :class:`RegexPattern` instance. *pattern* (:class:`str`, :class:`bytes`, :class:`re.Pattern`, 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.Pattern`) 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. Nzinclude:z must be null when pattern:z is a string.r"z is null.zpattern:z& is not a string, re.Pattern, or None.) isinstancer+bytespattern_to_regexrecompilehasattr TypeErrorsuperr.rr/r0)rr/rr0rs rrzRegexPattern.__init___s&#u& /wk4WK}M/))'2>5' JJu Eww8 5 /wk4WKyI/ Xg[(NO PP d$W-3:$, "$*rotherct|tr4|j|jk(xr|j|jk(StS)z Tests the equality of this regex pattern with *other* (:class:`RegexPattern`) by comparing their :attr:`~Pattern.include` and :attr:`~RegexPattern.regex` attributes. )r2r.rr0NotImplemented)rr:s r__eq__zRegexPattern.__eq__s9 |$ ,,%-- ' EDJJ%++,EE rr!RegexMatchResultcl|j(|jj|}| t|Sy)a  Matches this pattern against the specified file. *file* (:class:`str`) contains each file relative to the root directory (e.g., "relative/path/to/file"). Returns the match result (:class:`.RegexMatchResult`) if *file* matched; otherwise, :data:`None`. N)rr0r"r>)rr!r"s rr zRegexPattern.match_files6 \\ ::  D !5  E "" rc |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,)rr/s rr4zRegexPattern.pattern_to_regexs $r)N)r%r&r'r(r)r r PatternHintrr*rr=r+r classmethodr r4 __classcell__)rs@rr.r.Ss !7 d* +7 D>7 7r  D CH-?$@"CE#t),<rr.c eZdZUdZdZeed<y)r>zq The :class:`RegexMatchResult` data class is used to return information about the matched regular expression. )r"r"N)r%r&r'r(r) MatchHint__annotations__r,rrr>r>s  rr>)r( dataclassesr5rtypingrrrrrrErr rAr r objectr. dataclassr>r,rrrKsf    < f< ~p7pfvr