Files
intellecton/venv/lib/python3.12/site-packages/pathspec/__pycache__/pathspec.cpython-312.pyc
T

276 lines
20 KiB
Plaintext
Raw Normal View History

Ë
JÀjüAãó—dZddlmZddlmZmZmZmZddlm Z ddl
m Z m Z m
Z
mZmZmZmZmZedd¬«Z dd lmZdd
lmZmZmZdd lmZdd lmZdd
lmZddl m!Z!m"Z"ddl#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+Gd„de e'«Z,y)zn
This module provides :class:`.PathSpec` which is an object-oriented interface
for pattern matching of files.
é)Ú annotations)Ú
CollectionÚIterableÚIteratorÚSequence)Ú zip_longest)ÚCallableÚGenericÚLiteralÚOptionalÚTypeVarÚUnionÚcastÚoverloadÚSelfÚPathSpec)Úbound)Úutil)ÚBackendNamesHintÚ_BackendÚ_TestBackendFactoryHint©Úmake_pathspec_backend)ÚPattern)ÚGitIgnoreBasicPattern)ÚAnyStrÚ
deprecated)Ú CheckResultÚStrPathÚTPatternÚ TPattern_coÚTStrPathÚ TreeEntryÚ _is_iterableÚnormalize_filecó”—eZdZdZdddœ dd„Zdd„Zdd„Zdd„Zdd„Zdd „Z d d!d
„Z
d d"d „Z d# d$d „Z e
edddœ d%d
„««Ze
edddœ d&d„««Ze
edddœ d'd„««Ze
edddœ d(d„««Zedddœ d)d„«Ze d*d„«Z d ddœ d+d„Z d d,d„Z d ddœ d-d„Z d#ddœ d.d„Zed«d/d„«Z d#ddœ d0d„Zy)1rzd
The :class:`PathSpec` class is a wrapper around a list of compiled
:class:`.Pattern` instances.
N©ÚbackendÚ_test_backend_factorycóЗt|t«r|}n t|«}|€d}tt|«}|� ||«}n|j ||«}||_ ||_ ||_y)a
Initializes the :class:`.PathSpec` instance.
*patterns* (:class:`~collections.abc.Sequence` or :class:`~collections.abc.Iterable`)
contains each compiled pattern (:class:`.Pattern`). If not a sequence, it
will be converted to a :class:`list`.
*backend* (:class:`str` or :data:`None`) is the pattern (regular expression)
matching backend to use. Default is :data:`None` for "best" to use the best
available backend. Priority of backends is: "re2", "hyperscan", "simple".
The "simple" backend is always available.
NÚbest) Ú
isinstancerÚlistrrÚ
_make_backendÚ_backendÚ
_backend_nameÚpatterns)Úselfr1r(r)Ú use_patternsÚ backend_nameÚ use_backends úT/home/antigravity/intellecton/venv/lib/python3.12/site-packages/pathspec/pathspec.pyÚ__init__zPathSpec.__init__=s~€ô&�œ(Ô#Ø�<ä�x“.€<à €_Ø
€7äÔ&¨Ó0€,ØÐ&Ù& |Ó4�;à×#Ñ# L°,Ó?€;à'€$„-ðð
*6€$Ôðð*6€$„-ðócóh—|jj›d|j›d|j›d�S)z7
Returns a debug representation of this path-spec.
z
(patterns=z
, backend=ú))Ú __class__Ú__name__r1r0©r2s r6Ú__repr__zPathSpec.__repr__os5€ð
�N‰N× #Ñ #Ð $ J¨t¯}©}Ð.?¸zÈ$×J\ÑJ\ÐI_Ð_`Ð aÐar8có˜—t|t«r5|jg|j¢|j¢|j¬«St
S)zn
Combines the :attr:`self.patterns <.PathSpec.patterns>` patterns from two
:class:`PathSpec` instances.
)r()r,rr;r1r0ÚNotImplemented©r2Úothers r6Ú__add__zPathSpec.__add__us@€ô
�”xÔ Ø
�.‰.Ð:˜4Ÿ=™=Ð:¨5¯>©>Ð:ÀD×DVÑDVˆ.Ó
WÐWä
Ðr8có’—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:`self.patterns <.PathSpec.patterns>` attributes.
c3ó,K—|] \}}||k(–—Œy­w©N©)Ú.0ÚaÚbs r6ú <genexpr>z"PathSpec.__eq__.<locals>.<genexpr>†sèø€Ò
1™˜˜Aˆa�1�fÑ
1ùs‚)r,rrr1Úallr@)r2rBÚpaired_patternss r6Ú__eq__zPathSpec.__eq__s9€ô
�”xÔ Ü  §¡°·±Ó?€?Ü
Ñ
1 Ô
1Ó
1Ð1ä
Ðr8cóÆ—t|t«rLg|j¢|j¢|_|j|j|j«|_|St S)zn
Adds the :attr:`self.patterns <.PathSpec.patterns>` from *other*
(:class:`PathSpec`) to this instance.
)r,rr1r.r0r/r@rAs r6Ú__iadd__zPathSpec.__iadd__ŠsP€ô
�”xÔ Ø4�T—]‘]Ð4 U§^¡^Ð4€4„=Ø×%Ñ% d×&8Ñ&8¸$¿-¹-ÓH€4„=Ø
€;ä
Ðr8có,—t|j«S)zp
Returns the number of :attr:`self.patterns <.PathSpec.patterns>` this
path-spec contains (:class:`int`).
)Úlenr1r=s r6Ú__len__zPathSpec.__len__–s€ô
ˆT�]‰]Ó Ðr8cóp—t||«}|jj|«\}}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 <.PathSpec.patterns>`.
*separators* (:class:`~collections.abc.Collection` of :class:`str`; or
:data:`None`) optionally contains the path separators to normalize. See
:func:`.normalize_file` for more information.
Returns the file check result (:class:`.CheckResult`).
)r%r/Ú
match_filer)r2ÚfileÚ
separatorsÚ norm_fileÚincludeÚindexs r6Ú
check_filezPathSpec.check_file�s7€ô"˜T :Ó.€)Ø—=‘=×+Ñ+¨IÓ6�.€'ˆ5Ü �T˜7 EÓ *Ð*r8c#óÀK—t|«std|›d�«‚|D];}t||«}|jj |«\}}t |||«–—Œ=y­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 <.PathSpec.patterns>`.
*separators* (:class:`~collections.abc.Collection` of :class:`str`; or
:data:`None`) optionally contains the path separators to normalize. See
:func:`.normalize_file` for more information.
Returns an :class:`~collections.abc.Iterator` yielding each file check
result (:class:`.CheckResult`).
úfiles:ú is not an iterable.N)r$Ú TypeErrorr%r/rUr)r2ÚfilesrWÚ orig_filerXrYrZs r6Ú check_fileszPathSpec.check_files²sgèø€ô&
�eÔ Ü �V˜E˜9Ð$8Ð9Ó :Ð:àò0€iܘi¨Ó4€9Ø—M‘M×,Ñ,¨YÓ7�>€7ˆEÜ �Y ¨Ó /Ó/ñ0ùs‚AAc#ó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:`.CheckResult`).
©Úon_errorÚ follow_linksN)rÚiter_tree_filesrb)r2Úrootrerfr`s r6Úcheck_tree_fileszPathSpec.check_tree_filesÍs0èø€ô< ×
Ñ
˜t¨hÀ\Ô
R€%Ø
×
Ñ
˜eÓ
$×$Ò$ús ‚-7¯5°7có—yrFrG©ÚclsÚpattern_factoryÚlinesr(r)s r6Ú
from_lineszPathSpec.from_linesîó€ðr8có—yrFrGrks r6rozPathSpec.from_linesúrpr8có—yrFrGrks r6rozPathSpec.from_linesrpr8có—yrFrGrks r6rozPathSpec.from_linesrpr8có—t|t«rtj|«}nt |«r|}nt d|›d�«‚t
|«st d|›d�«‚|D�cgc]
}|sŒ||«‘Œ}}||||¬«}|Scc}w)a‚
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`.
*backend* (:class:`str` or :data:`None`) is the pattern (or regular
expression) matching backend to use. Default is :data:`None` for "best" to
use the best available backend. Priority of backends is: "re2", "hyperscan",
"simple". The "simple" backend is always available.
Returns the :class:`PathSpec` instance.
zpattern_factory:z is not callable.zlines:r^r')r,ÚstrrÚlookup_patternÚcallabler_r$) rlrmrnr(r)Ú use_factoryÚ_PathSpec__liner1r2s r6rozPathSpec.from_liness“€ô<�¤Ô%Ü×$Ñ$ _Ó5�;Ü�Ô Ø �;ä Ð% oÐ%8Ð8IÐJÓ KÐKä �eÔ Ü �V˜E˜9Ð$8Ð9Ó :Ð:à05Ö
@ fº‰k˜&Õ!Ð
@€(Ð
@Ù ˆX˜wÐ>SÔ T€$Ø
€+ùòAs Á"BÁ*
Bcó—t||«S)aM
.. warning:: This method is not part of the public API. It is subject to
change.
Create the backend for the patterns.
*name* (:class:`str`) is the name of the backend.
*patterns* (:class:`~collections.abc.Sequence` of :class:`.Pattern`)
contains the compiled patterns.
Returns the matcher (:class:`._Backend`).
r)Únamer1s r6r.zPathSpec._make_backendJs€ô$
˜t XÓ .Ð.r8©Únegatec#óÎK—t|«std|›d�«‚|D]B}t|j|«}|jj |«\}}|r| }|sŒ?|–—ŒDy­w)aÞ
Matches the entries to this path-spec.
*entries* (:class:`~collections.abc.Iterable` of :class:`.TreeEntry`)
contains the entries to be matched against :attr:`self.patterns <.PathSpec.patterns>`.
*separators* (:class:`~collections.abc.Collection` of :class:`str`; or
:data:`None`) optionally contains the path separators to normalize. See
:func:`.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:`.TreeEntry`).
zentries:r^N)r$r_r%Úpathr/rU)r2ÚentriesrWr}ÚentryrXrYÚ_indexs r6Ú
match_entrieszPathSpec.match_entries^snèø€ô2
�gÔ Ü �X˜g˜[Ð(<Ð=Ó >Ð>àò€eܘeŸj™j¨*Ó5€9Ø—]‘]×-Ñ-¨iÓ8�?€7ˆFá Øˆk€Gâ
Ø
ƒKñùs ‚AA%ÁA%cól—t||«}|jj|«\}}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 <.PathSpec.patterns>`.
*separators* (:class:`~collections.abc.Collection` of :class:`str`)
optionally contains the path separators to normalize. See
:func:`.normalize_file` for more information.
Returns :data:`True` if *file* matched; otherwise, :data:`False`.
)r%r/rUÚbool)r2rVrWrXrYr‚s r6rUzPathSpec.match_file„s2€ô"˜T :Ó.€)Ø—M‘M×,Ñ,¨YÓ7�/€'ˆ6Ü
ˆg‹Ðr8c#óºK—t|«std|›d�«‚|D]8}t||«}|jj |«\}}|r| }|sŒ5|–—Œ:y­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 <.PathSpec.patterns>`.
*separators* (:class:`~collections.abc.Collection` of :class:`str`; or
:data:`None`) optionally contains the path separators to normalize. See
:func:`.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`).
r]r^N)r$r_r%r/rU)r2r`rWr}rarXrYr‚s r6Ú match_fileszPathSpec.match_files™sjèø€ô4
�eÔ Ü �V˜E˜9Ð$8Ð9Ó :Ð:àò€iܘi¨Ó4€9Ø—]‘]×-Ñ-¨iÓ8�?€7ˆFá Øˆk€Gâ
Ø
ƒOñùs ‚AAÁAc#ó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`).
rdr|N)rÚiter_tree_entriesrƒ)r2rhrerfr}r€s r6Úmatch_tree_entrieszPathSpec.match_tree_entriesÀs6èø€ô@
× "Ñ " 4°(ÈÔ V€'Ø
×
Ñ
 °Ð
Ó
7×7Ò7úó ‚/9±7²9zEPathSpec.match_tree() is deprecated. Use .match_tree_files() instead.có&—|j|i|¤ŽS)z…
.. version-deprecated:: 0.3.2
This is an alias for the :meth:`self.match_tree_files <.PathSpec.match_tree_files>`
method.
)Úmatch_tree_files)r2ÚargsÚkws r6Ú
match_treezPathSpec.match_treeäs€ð
ˆ× Ñ  Ð +¨Ñ +Ð+r8c#ó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