Ë Q¡"¥býf ãó´—dZddlmZddlmZddlmZmZmZm Z m Z m Z m Z m Z mZddlmZddlmZddlmZmZmZmZmZmZmZe d d ¬ «Z Gd „d e«Zy )zR This module provides an object oriented interface for pattern matching of files. é)Ú Collection)Ú zip_longest) ÚAnyStrÚCallablerÚIterableÚIteratorÚOptionalÚTypeÚTypeVarÚUnioné)Úutil)ÚPattern)Ú CheckResultÚStrPathÚTStrPathÚ TreeEntryÚ_filter_check_patternsÚ _is_iterableÚnormalize_fileÚSelfÚPathSpec)Úboundc ó¶—eZdZdZdeeddfd„Zdedefd„Z de fd„Z d e ddde fd „Z d e ddde fd „Z d!d ed eeedeefd„Z d!deed eeedeeefd„Z d"dedeeegdfdeedeeefd„Zedee deeeegeffdeede fd„«Z d!ddœdee d eeedeedee fd„Z!e"e#jH«Z% d!d ed eeedefd„Z& d!ddœdeed eeedeedeefd„Z' d"ddœdedeeegdfdeedeedee f d„Z( d"ddœdedeeegdfdeedeedeef d „Z)e)Z*y)#rzd The :class:`PathSpec` class is a wrapper around a list of compiled :class:`.Pattern` instances. ÚpatternsÚreturnNcóH—t|t«s t|«}||_y)zÀ Initializes the :class:`PathSpec` instance. *patterns* (:class:`~collections.abc.Collection` or :class:`~collections.abc.Iterable`) yields each compiled pattern (:class:`.Pattern`). N)Ú isinstanceÚCollectionTypeÚlistr)Úselfrs ú6/usr/lib/python3.12/site-packages/pathspec/pathspec.pyÚ__init__zPathSpec.__init__-s#€ô �HœnÔ -Ü�8‹n€8à'/€$„-ðóÚothercó’—t|t«r2t|j|j«}t d„|D««St S)z‡ Tests the equality of this path-spec with *other* (:class:`PathSpec`) by comparing their :attr:`~PathSpec.patterns` attributes. c3ó,K—|] \}}||k(–—Œy­w©N©)Ú.0ÚaÚbs r"Ú z"PathSpec.__eq__..Dsèø€Ð 1¡™˜˜Aˆa�1�f¡ùs‚)rrrrÚallÚNotImplemented)r!r%Úpaired_patternss r"Ú__eq__zPathSpec.__eq__=s9€ô �”xÔ Ü  §¡°·±Ó?€?Ü Ñ 1¡Ó 1Ó 1Ð1ä Ðr$có,—t|j«S)zW Returns the number of compiled patterns this path-spec contains (:class:`int`). )Úlenr)r!s r"Ú__len__zPathSpec.__len__Hs€ô ˆT�]‰]Ó Ðr$r!có~—t|t«r(|j|j|jz«StS)z] Combines the :attr:`Pathspec.patterns` patterns from two :class:`PathSpec` instances. )rrÚ __class__rr/©r!r%s r"Ú__add__zPathSpec.__add__Os0€ô �”xÔ Ø �.‰.˜Ÿ™¨¯©Ñ7Ó 8Ð8ä Ðr$cóp—t|t«r!|xj|jz c_|StS)zi Adds the :attr:`Pathspec.patterns` patterns from one :class:`PathSpec` instance to this instance. )rrrr/r7s r"Ú__iadd__zPathSpec.__iadd__Ys+€ô �”xÔ Ø‡=‚=�E—N‘NÑ"…=Ø €;ä Ðr$ÚfileÚ separatorscó„—t||«}|jt|j«|«\}}t |||«S)aÌ Check the files against this path-spec. *file* (:class:`str` or :class:`os.PathLike`) is the file path to be matched against :attr:`self.patterns `. *separators* (:class:`~collections.abc.Collection` of :class:`str`; or :data:`None`) optionally contains the path separators to normalize. See :func:`~pathspec.util.normalize_file` for more information. Returns the file check result (:class:`~pathspec.util.CheckResult`). )rÚ _match_fileÚ enumeraterr)r!r;r<Ú norm_fileÚincludeÚindexs r"Ú check_filezPathSpec.check_fileds>€ô"˜T :Ó.€)Ø×#Ñ#¤I¨d¯m©mÓ$<¸iÓH�.€'ˆ5Ü �T˜7 EÓ *Ð*r$Úfilesc#óØK—t|«std|›d�«‚t|j«}|D]2}t ||«}|j ||«\}}t |||«–—Œ4y­w)a. Check the files against this path-spec. *files* (:class:`~collections.abc.Iterable` of :class:`str` or :class:`os.PathLike`) contains the file paths to be checked against :attr:`self.patterns `. *separators* (:class:`~collections.abc.Collection` of :class:`str`; or :data:`None`) optionally contains the path separators to normalize. See :func:`~pathspec.util.normalize_file` for more information. Returns an :class:`~collections.abc.Iterator` yielding each file check result (:class:`~pathspec.util.CheckResult`). úfiles:ú is not an iterable.N)rÚ TypeErrorrrrr>r)r!rDr<Ú use_patternsÚ orig_filer@rArBs r"Ú check_fileszPathSpec.check_filesysnèø€ô& �eÔ Ü �V˜E˜9Ð$8Ð9Ó :Ð:ä'¨¯ © Ó6€,Û€iܘi¨Ó4€9Ø×$Ñ$ \°9Ó=�>€7ˆEÜ �Y ¨Ó /Ó/ñùs‚A(A*ÚrootÚon_errorÚ follow_linksc#órK—tj|||¬«}|j|«Ed{–—†y7Œ­w)aê Walks the specified root path for all files and checks them against this path-spec. *root* (:class:`str` or :class:`os.PathLike`) is the root directory to search for files. *on_error* (:class:`~collections.abc.Callable` or :data:`None`) optionally is the error handler for file-system exceptions. It will be called with the exception (:exc:`OSError`). Reraise the exception to abort the walk. Default is :data:`None` to ignore file-system exceptions. *follow_links* (:class:`bool` or :data:`None`) optionally is whether to walk symbolic links that resolve to directories. Default is :data:`None` for :data:`True`. *negate* (:class:`bool` or :data:`None`) is whether to negate the match results of the patterns. If :data:`True`, a pattern matching a file will exclude the file rather than include it. Default is :data:`None` for :data:`False`. Returns an :class:`~collections.abc.Iterator` yielding each file check result (:class:`~pathspec.util.CheckResult`). ©rMrNN)rÚiter_tree_filesrK)r!rLrMrNrDs r"Úcheck_tree_fileszPathSpec.check_tree_files•s0èø€ô< × Ñ ˜t¨hÀ\Ô R€%Ø × Ñ ˜eÓ $×$Ò$ús ‚-7¯5°7ÚclsÚpattern_factoryÚlinescóþ—t|t«rtj|«}t |«st d|›d�«‚t |«st d|›d�«‚|D�cgc] }|sŒ||«‘Œ}}||«Scc}w)ai Compiles the pattern lines. *pattern_factory* can be either the name of a registered pattern factory (:class:`str`), or a :class:`~collections.abc.Callable` used to compile patterns. It must accept an uncompiled pattern (:class:`str`) and return the compiled pattern (:class:`.Pattern`). *lines* (:class:`~collections.abc.Iterable`) yields each uncompiled pattern (:class:`str`). This simply has to yield each line so that it can be a :class:`io.TextIOBase` (e.g., from :func:`open` or :class:`io.StringIO`) or the result from :meth:`str.splitlines`. Returns the :class:`PathSpec` instance. zpattern_factory:z is not callable.zlines:rG)rÚstrrÚlookup_patternÚcallablerHr)rSrTrUÚliners r"Ú from_lineszPathSpec.from_lines¶s„€ô*�¤Ô%Ü×(Ñ(¨Ó9€?ä �/Ô "Ü Ð% oÐ%8Ð8IÐJÓ KÐKä �eÔ Ü �V˜E˜9Ð$8Ð9Ó :Ð:á05Ó >±¨º‰o˜dÕ#°€(Ð >Ù ˆX‹Ðùò?s ÁA:Á& A:©ÚnegateÚentriesr]c#óæK—t|«std|›d�«‚t|j«}|D]9}t |j |«}|j ||«\}}|r| }|sŒ6|–—Œ;y­w)a Matches the entries to this path-spec. *entries* (:class:`~collections.abc.Iterable` of :class:`~pathspec.util.TreeEntry`) contains the entries to be matched against :attr:`self.patterns `. *separators* (:class:`~collections.abc.Collection` of :class:`str`; or :data:`None`) optionally contains the path separators to normalize. See :func:`~pathspec.util.normalize_file` for more information. *negate* (:class:`bool` or :data:`None`) is whether to negate the match results of the patterns. If :data:`True`, a pattern matching a file will exclude the file rather than include it. Default is :data:`None` for :data:`False`. Returns the matched entries (:class:`~collections.abc.Iterator` of :class:`~pathspec.util.TreeEntry`). zentries:rGN)rrHrrrÚpathr>) r!r^r<r]rIÚentryr@rAÚ_indexs r"Ú match_entrieszPathSpec.match_entries×suèø€ô2 �gÔ Ü �X˜g˜[Ð(<Ð=Ó >Ð>ä'¨¯ © Ó6€,Û€eܘeŸj™j¨*Ó5€9Ø×%Ñ% l°IÓ>�?€7ˆFá Øˆk€Gâ Ø ƒKñùs ‚A'A1Á*A1có€—t||«}|jt|j«|«\}}t |«S)a´ Matches the file to this path-spec. *file* (:class:`str` or :class:`os.PathLike`) is the file path to be matched against :attr:`self.patterns `. *separators* (:class:`~collections.abc.Collection` of :class:`str`) optionally contains the path separators to normalize. See :func:`~pathspec.util.normalize_file` for more information. Returns :data:`True` if *file* matched; otherwise, :data:`False`. )rr>r?rÚbool)r!r;r<r@rArbs r"Ú match_filezPathSpec.match_files9€ô"˜T :Ó.€)Ø×$Ñ$¤Y¨t¯}©}Ó%=¸yÓI�/€'ˆ6Ü ˆg‹Ðr$c#óÒK—t|«std|›d�«‚t|j«}|D]/}t ||«}|j ||«\}}|r| }|sŒ,|–—Œ1y­w)a  Matches the files to this path-spec. *files* (:class:`~collections.abc.Iterable` of :class:`str` or :class:`os.PathLike`) contains the file paths to be matched against :attr:`self.patterns `. *separators* (:class:`~collections.abc.Collection` of :class:`str`; or :data:`None`) optionally contains the path separators to normalize. See :func:`~pathspec.util.normalize_file` for more information. *negate* (:class:`bool` or :data:`None`) is whether to negate the match results of the patterns. If :data:`True`, a pattern matching a file will exclude the file rather than include it. Default is :data:`None` for :data:`False`. Returns the matched files (:class:`~collections.abc.Iterator` of :class:`str` or :class:`os.PathLike`). rFrGN)rrHrrrr>) r!rDr<r]rIrJr@rArbs r"Ú match_fileszPathSpec.match_filessqèø€ô4 �eÔ Ü �V˜E˜9Ð$8Ð9Ó :Ð:ä'¨¯ © Ó6€,Û€iܘi¨Ó4€9Ø×%Ñ% l°IÓ>�?€7ˆFá Øˆk€Gâ Ø ƒOñùs ‚AA'Á A'c#óvK—tj|||¬«}|j||¬«Ed{–—†y7Œ­w)a¾ Walks the specified root path for all files and matches them to this path-spec. *root* (:class:`str` or :class:`os.PathLike`) is the root directory to search. *on_error* (:class:`~collections.abc.Callable` or :data:`None`) optionally is the error handler for file-system exceptions. It will be called with the exception (:exc:`OSError`). Reraise the exception to abort the walk. Default is :data:`None` to ignore file-system exceptions. *follow_links* (:class:`bool` or :data:`None`) optionally is whether to walk symbolic links that resolve to directories. Default is :data:`None` for :data:`True`. *negate* (:class:`bool` or :data:`None`) is whether to negate the match results of the patterns. If :data:`True`, a pattern matching a file will exclude the file rather than include it. Default is :data:`None` for :data:`False`. Returns the matched files (:class:`~collections.abc.Iterator` of :class:`.TreeEntry`). rPr\N)rÚiter_tree_entriesrc)r!rLrMrNr]r^s r"Úmatch_tree_entrieszPathSpec.match_tree_entriesBs6èø€ô@ × "Ñ " 4°(ÈÔ V€'Ø × Ñ  °Ð Ó 7×7Ò7úó ‚/9±7²9c#óvK—tj|||¬«}|j||¬«Ed{–—†y7Œ­w)aÁ Walks the specified root path for all files and matches them to this path-spec. *root* (:class:`str` or :class:`os.PathLike`) is the root directory to search for files. *on_error* (:class:`~collections.abc.Callable` or :data:`None`) optionally is the error handler for file-system exceptions. It will be called with the exception (:exc:`OSError`). Reraise the exception to abort the walk. Default is :data:`None` to ignore file-system exceptions. *follow_links* (:class:`bool` or :data:`None`) optionally is whether to walk symbolic links that resolve to directories. Default is :data:`None` for :data:`True`. *negate* (:class:`bool` or :data:`None`) is whether to negate the match results of the patterns. If :data:`True`, a pattern matching a file will exclude the file rather than include it. Default is :data:`None` for :data:`False`. Returns the matched files (:class:`~collections.abc.Iterable` of :class:`str`). rPr\N)rrQrh)r!rLrMrNr]rDs r"Úmatch_tree_fileszPathSpec.match_tree_fileses6èø€ô@ × Ñ ˜t¨hÀ\Ô R€%Ø × Ñ ˜e¨FÐ Ó 3×3Ò3úrlr()NN)+Ú__name__Ú __module__Ú __qualname__Ú__doc__rrr#Úobjectrer1Úintr4rr8r:rr rrWrrCrrKrrÚOSErrorrRÚ classmethodr r rr[rrcÚ staticmethodrÚcheck_match_filer>rfrhrkrnÚ match_treer)r$r"rr'sH„ñð ˜h wÑ/ð°Dóð ˜ð  Dó ð�cóð�4ð  ð¨tóð �Dð  ð °ó ð+/ñ+àð+ð�z #‘Ñ'ð+ð�(Ñó +ð0+/ñ0à �(Ñ ð0ð�z #‘Ñ'ð0ðˆ{˜8Ñ$Ñ%ó 0ð>37Ø!%ñ %àð%ð �X˜w˜i¨˜oÑ.Ñ /ð%ð˜‘ð %ð ˆ{˜3ÑÑ ó %ðBðØ ˆD�zðà˜˜h¨ x°Ð'8Ñ9Ð9Ñ:ðð �&Ñ ðð ò óððF+/ð%ð  ò %à �IÑ ð%ð�z #‘Ñ'ð%ð �4‰.ð %ð ˆyÑó %ñN˜D×1Ñ1Ó2€ðð+/ñàðð�z #‘Ñ'ðð ó ð0+/ð&ð  ò &à �'Ñ ð&ð�z #‘Ñ'ð&ð �4‰.ð &ð ˆwÑó &ðV37Ø!%ð !8ð  ò !8àð!8ð �X˜w˜i¨˜oÑ.Ñ /ð!8ð˜‘ð !8ð �4‰.ð !8ðˆyÑó!8ðL37Ø!%ð !4ð  ò !4àð!4ð �X˜w˜i¨˜oÑ.Ñ /ð!4ð˜‘ð !4ð �4‰.ð !4ðˆs�mó!4ðJ�r$N)rrÚcollections.abcrrÚ itertoolsrÚtypingrrrrr r r r ÚrÚpatternrrrrrrrrrrsrr)r$r"Úrs]ðñõõ÷ ÷ õ õõ ÷÷ññˆv˜ZÔ(€ðô cˆvõcr$