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ü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+Gdde 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œ ddZddZddZddZddZdd „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+dZ d d,dZ d ddœ d-dZ d#ddœ d.dZed«d/d«Z d#ddœ d0dZy)1rzd
The :class:`PathSpec` class is a wrapper around a list of compiled
:class:`.Pattern` instances.
Ú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.
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|jjd|jd|jdS)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ˆ

Ð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©)Ú.0Úbs r6ú <genexpr>z"PathSpec.__eq__.<locals>.<genexpr>†sèø€Ò
1™˜˜Aˆa1
1ùs)r,rrr1Úallr@)r2rBÚpaired_patternss r6Ú__eq__zPathSpec.__eq__s9ô
”xÔ Ü  §¡°·±Ó?€?Ü
Ñ
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Ô Ø4T—]‘]Ð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ópt||«}|jj|«\}}t|||«S)
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_files7ô"˜T .€)Ø—==×+¨IÓ6.€'ˆT˜7 EÓ *Ð*r8c#óÀKt|«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èø€ô&
Ü V˜E˜9Ð$8Ð9Ó :Ðò0€iܘi¨Ó4€9Ø—MM×,¨YÓ7>€7ˆY ¨Ó /Ó0ùsAAc#órKtj|||¬«}|j|«Ed{y7Œ­w)
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€%Ø
×
Ñ
˜
$×$ú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«|Dcgc]
}|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ÐÜ V˜E˜9Ð$8Ð9Ó :Ð:à05Ö
@ ‰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#óÎKt|«std|d«|D]B}t|j|«}|jj |«\}}|r| }|sŒ?|ŒDy­w)
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
Ü X˜g˜[Ð(<Ð=Ó >Ðò€eܘeŸj™j¨*Ó5€9Ø—]‘]×-¨iÓ8?€7ˆFá Øˆk€Gâ
Ø
ƒKñùs AA%ÁA%cólt||«}|jj|«\}}t|«S)
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)r2rVrWrXrYrs r6rUzPathSpec.match_file„s2ô"˜T .€)Ø—MM×,¨YÓ7/€'ˆ
ˆgÐr8c#óºKt|«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}rarXrYrs r6Ú match_fileszPathSpec.match_files™sjèø€ô4
Ü V˜E˜9Ð$8Ð9Ó :Ðò€iܘi¨Ó4€9Ø—]‘]×-¨iÓ8?€7ˆFá Øˆk€Gâ
Ø
ƒOñùs AAÁAc#óvKtj|||¬«}|j||¬«Ed{y7Œ­w)
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úó /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#óvKtj|||¬«}|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