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

388 lines
28 KiB
Plaintext
Raw Normal View History

Ë
JÀjÏcãó²—UdZddlmZddlZddlZddlZddlZddlZddlm Z m
Z
m Z m Z ddl
mZddlmZmZmZmZmZmZmZddlmZdd lmZmZeeej:efZed
e¬ «Z ed ed
¬«Z ede¬ «Z! ejDejFfD�cgc]}|r|ejDk7r ee|«‘Œc}Z$ iZ%de&d< d0d„Z' d1 d2d„Z( d1 d3d„Z) d4d„Z*d5d„Z+ed«d6d„«Z, d6 d7d„Z- d8d„Z. d6 d9d„Z/ d:d„Z0d;d„Z1d<d„Z2ed« d=d „«Z3 d1 d>d!„Z4ed"« d1 d?d#„«Z5 d1 d@d$„Z6Gd%„d&e7«Z8Gd'„d(e7«Z9ed
¬)«Gd*„d+ee!««Z:Gd,„d-e;«Z<Gd.„d/e;«Z=ycc}w)AzC
This module provides utility methods for dealing with path-specs.
é)Ú annotationsN)Ú
CollectionÚIterableÚIteratorÚSequence)Ú dataclass)ÚAnyÚCallableÚGenericÚOptionalÚTypeVarÚUnionÚcasté)ÚPattern)ÚAnyStrÚ
deprecatedÚTPattern)ÚboundÚ TPattern_coT)rÚ covariantÚTStrPathz1dict[str, Callable[[Union[str, bytes]], Pattern]]Ú_registered_patternscób—t|«}|j«r|tjz
}|S)a4
Appends the path separator to the path if the path is a directory. This can be
used to aid in distinguishing between directories and files on the file-system
by relying on the presence of a trailing path separator.
*path* (:class:`pathlib.Path`) is the path to use.
Returns the path (:class:`str`).
)ÚstrÚis_dirÚosÚsep)ÚpathÚstr_paths úP/home/antigravity/intellecton/venv/lib/python3.12/site-packages/pathspec/util.pyÚappend_dir_sepr"Gs)€ô
�‹I€Ø‡K�K„MØ
Œb�f‰fÑ€(à€ócóö—|r9|D]3\}}|j€Œ|j|«€Œ%|j|fcSyd}d}|D]2\}}|j€Œ|j|«€Œ%|j}|}Œ4||fS)a±
Check the file against the patterns.
*patterns* (:class:`~collections.abc.Iterable`) yields each indexed pattern
(:class:`tuple`) which contains the pattern index (:class:`int`) and actua
pattern (:class:`.Pattern`).
*file* (:class:`str`) is the normalized file path to be matched against
*patterns*.
*is_reversed* (:class:`bool` or :data:`None`) is whether the order of the
patterns has been reversed. Default is :data:`None` for :data:`False`.
Reversing the order of the patterns is an optimization.
Returns a :class:`tuple` containing whether to include *file* (:class:`bool`
or :data:`None`), and the index of the last matched pattern (:class:`int` or
:data:`None`).
N©NN©ÚincludeÚ
match_file)ÚpatternsÚfileÚ is_reversedÚindexÚpatternÚ out_includeÚ out_indexs r!Úcheck_match_filer0Xsž€ñ.ð!ò"�n€eˆWØ
‡o�oÑ! g×&8Ñ&8¸Ó&>Ñ&JØ �?‰?˜EÐ !Ò!ð"ð
ð!%€+Ø!€)Ø ò�n€eˆWØ
‡o�oÑ! g×&8Ñ&8¸Ó&>Ñ&JØ—/‘/€KØ�Iðð
�iÐ Ðr#cóX—t|t«r|n
t|«}i}|D]…}|j€Œ|j |«}|jrO|D]I}||vr4|r||j
j
|«Œ(|||j
d<Œ;t|g«||<ŒKŒ||D]}||=ŒŒ‡|S)a¡
Matches the files to the patterns, and returns which patterns matched the
files.
*patterns* (:class:`~collections.abc.Iterable` of :class:`.Pattern`) contains
the patterns to use.
*files* (:class:`~collections.abc.Iterable` of :class:`str`) contains the
normalized file paths to be matched against *patterns*.
*all_matches* (:class:`bool` or :data:`None`) is whether to return all matches
patterns (:data:`True`), or only the last matched pattern (:data:`False`).
Default is :data:`None` for :data:`False`.
Returns the matched files (:class:`dict`) which maps each matched file
(:class:`str`) to the patterns that matched in order (:class:`.MatchDetail`).
r)Ú
isinstancerÚlistr'Úmatchr)ÚappendÚ MatchDetail) r)ÚfilesÚ all_matchesÚ all_filesÚ return_filesr-Ú result_filesÚ result_filer*s r!Údetailed_match_filesr=„sÅ€ô,! ¬
Ô3‰U¼¸e»€Ø(*€Øò€WØ ‡_�_Ñ Ø—-‘-  Ó*€<Ø
‡o‚oà#ò9ˆ Ø�|Ñ#á Ø�KÑ ×)Ñ)×0Ñ0°Õ9à/6€|�KÑ ×)Ñ)¨!Ò,ä"-¨w¨iÓ"8€l�;Òñ9ðòˆØ �dÑ ñð#ð( Ðr#cóf—t|«D��cgc]\}}|j�||f‘Œc}}Scc}}w)a&
Filters out null-patterns.
*patterns* (:class:`~collections.abc.Iterable` of :class:`.Pattern`) contains
the patterns.
Returns a :class:`list` containing each indexed pattern (:class:`tuple`) which
contains the pattern index (:class:`int`) and the actual pattern
(:class:`.Pattern`).
)Ú enumerater')r)Ú__indexÚ__pats r!Ú_filter_check_patternsrB³s<€ô" (Ó+÷ á€gˆuØ
‡]�]Ðð ˆEÒó ðùó s�-cóT—t|t«xrt|ttf« S)z™
Check whether the value is an iterable (excludes strings).
*value* is the value to check,
Returns whether *value* is an iterable (:class:`bool`).
)r2rrÚbytes)Úvalues r!Ú _is_iterablerFÇs$€ô �5œ(Ó#ÒK¬J°u¼sÄE¸lÓ,KÐ(KÐKr#zGpathspec.util.iter_tree() is deprecated. Use iter_tree_files() instead.có—t|||¬«S)z`
.. version-deprecated:: 0.10.0
This is an alias for the :func:`.iter_tree_files` function.
)Úon_errorÚ follow_links)Úiter_tree_files©ÚrootrHrIs r!Ú iter_treerMÒs€ô ˜ x¸lÔKÐKr#c#ó¸K—|�t|«std|›d�«‚|€d}ttjj |«di||«Ed{–—†y7Œ­w)a
Walks the specified directory for all files and directories.
*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`.
Raises :exc:`.RecursionError` if recursion is detected.
Returns an :class:`~collections.abc.Iterator` yielding each file or directory
entry (:class:`.TreeEntry`) relative to *root*.
Nú on_error:ú is not callable.TÚ)ÚcallableÚ TypeErrorÚ_iter_tree_entries_nextrrÚabspathrKs r!Úiter_tree_entriesrVÝsXèø€ð0
Ф¨(Ô!3Ü�I˜h˜\Ð):Ð;Ó<Ð<àÐØ€,ä #¤B§G¡G§O¡O°DÓ$9¸2¸rÀ8È\Ó Z×ZÒZúó‚AAÁAÁAc #óxK—tjj||«}tjj|«}||vr|||<nt ||||¬«‚tj
|«5}|D]â}tjj||j «} |jd¬«}
|j«r |j«} n|
} |j|¬«r2t|j | |
| «–—t|| |||«Ed{–—†Œ¨|j«s|j«sŒÉt|j | |
| «–—Œä ddd«||=y#t$r} |�|| «Yd} ~ �Œ d} ~ wwxYw#t$r} |�|| «Yd} ~ �Œ,d} ~ wwxYw7Œ‘#1swY||=yxYw­w)ap
Scan the directory for all descendant files.
*root_full* (:class:`str`) the absolute path to the root directory.
*dir_rel* (:class:`str`) the path to the directory to scan relative to
*root_full*.
*memo* (:class:`dict`) keeps track of ancestor directories encountered. Maps
each ancestor real path (:class:`str`) to relative path (:class:`str`).
*on_error* (:class:`~collections.abc.Callable` or :data:`None`) optionally is
the error handler for file-system exceptions.
*follow_links* (:class:`bool`) is whether to walk symbolic links that resolve
to directories.
Yields each entry (:class:`.TreeEntry`).
©Ú real_pathÚ
first_pathÚ second_pathF©Úfollow_symlinksN)rrÚjoinÚrealpathÚRecursionErrorÚscandirÚnameÚstatÚOSErrorÚ
is_symlinkrÚ TreeEntryrTÚis_file)
Ú root_fullÚdir_relÚmemorHrIÚdir_fullÚdir_realÚ scan_iterÚnode_entÚnode_relÚ
node_lstatÚeÚ node_stats
r!rTrTþs èø€ô4
�G‰G�L‰L˜ GÓ ,€Ü �G‰G× Ñ ˜XÓ &€ð
�DÑØ€$€x‚.ä °d¸8±nÐRYÔZÐZä‡j�j�Óð!D˜iàòD€hÜ�g‰g�l‰l˜7 H§M¡MÓ2€8ð
Ø—‘¨u�Ó5€Jð ×ÑÔðØ—‘“�Yð €Ià‡o�o l€oÔ3ô �H—M‘M 8¨Z¸Ó
CÒCä& y°(¸DÀ(ÈLÓY×YÑYà×ÑÔ˜h×1Ñ1Õ3ä
�H—M‘M 8¨Z¸Ó
CÓCñ?D÷!DðP
ˆ(�^øôA ò
ØÐÙ
ˆa„[Ý ûð
ûô òØÐÙˆq„kÝ
ûðúðZø÷;!DðP
ˆ(�^üs…‚A0F:Á20F+Â#E'Â5F+ÃFÃAF+ÄF)Ä%F+Ä>F+Å F:Å' FÅ0
FÅ:F+ÆFÆF+Æ F&Æ
F!ÆF+Æ!F&Æ&F+Æ+F7Æ0
F:c#ó¸K—|�t|«std|›d�«‚|€d}ttjj |«di||«Ed{–—†y7Œ­w)aû
Walks the specified directory for all files.
*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`.
Raises :exc:`.RecursionError` if recursion is detected.
Returns an :class:`~collections.abc.Iterator` yielding the path to each file
(:class:`str`) relative to *root*.
NrOrPTrQ)rRrSÚ_iter_tree_files_nextrrrUrKs r!rJrJMsXèø€ð2
Ф¨(Ô!3Ü�I˜h˜\Ð):Ð;Ó<Ð<àÐØ€,ä !¤"§'¡'§/¡/°$Ó"7¸¸RÀÈ<Ó X×XÒXúrWc #ó6K—tjj||«}tjj|«}||vr|||<nt ||||¬«‚tj
|«5}|D]ƒ}tjj||j «} |j|¬«rt|| |||«Ed{–—†ŒW|j«r| –—Œl|rŒo|j«sŒ€| –—Œ… ddd«||=y7ŒA#1swY||=yxYw­w)am
Scan the directory for all descendant files.
*root_full* (:class:`str`) the absolute path to the root directory.
*dir_rel* (:class:`str`) the path to the directory to scan relative to
*root_full*.
*memo* (:class:`dict`) keeps track of ancestor directories encountered. Maps
each ancestor real path (:class:`str`) to relative path (:class:`str`).
*on_error* (:class:`~collections.abc.Callable` or :data:`None`) optionally is
the error handler for file-system exceptions.
*follow_links* (:class:`bool`) is whether to walk symbolic links that resolve
to directories.
Yields each file path (:class:`str`).
rYr]N) rrr_r`rarbrcrrurhrf)
rirjrkrHrIrlrmrnrorps
r!ruruosþèø€ô4
�G‰G�L‰L˜ GÓ ,€Ü �G‰G× Ñ ˜XÓ &€ð
�DÑØ€$€x‚.ä °d¸8±nÐRYÔZÐZä‡j�j�Óð˜iàò€hÜ�g‰g�l‰l˜7 H§M¡MÓ2€8à‡o�o l€oÔ3ô% Y°¸$ÀÈ,ÓW×WÑWà×ÑÔà
ƒNâ ˜X×0Ñ0Õ2à
ƒNñ÷ð.
ˆ(�^ðXø÷ð.
ˆ(�^üs=‚A0DÁ2AD
ÃDÃD
Ã$D
Ã5D
Ã< DÄD
Ä
DÄ
Dcó—t|S)zû
Looks up a registered pattern factory by name.
*name* (:class:`str`) is the name of the pattern factory.
Returns the registered pattern factory (:class:`~collections.abc.Callable`).
If no pattern factory is registered, raises :exc:`KeyError`.
)r)rcs r!Úlookup_patternrx­s€ô ˜TÑ"Ð"r#cón—d}|D]-}|j€Œ|j|«€Œ"|j}Œ/|S)a&
Matches the file to the patterns.
*patterns* (:class:`~collections.abc.Iterable` of :class:`.Pattern`) contains
the patterns to use.
*file* (:class:`str`) is the normalized file path to be matched against
*patterns*.
Returns :data:`True` if *file* matched; otherwise, :data:`False`.
Fr&)r)r*Úmatchedr-s r!r(r(¹sB€ð €Øò€WØ ‡_�_Ñ  W×%7Ñ%7¸Ó%=Ñ%IØ
�_‰_�7ðð €r#z[pathspec.util.match_files() is deprecated. Use match_file() with a loop for better results.có¦—|D�cgc]}|j€Œ|‘Œ}}t«}|D] }t||«sŒ|j|«Œ"|Scc}w)aØ
.. version-deprecated:: 0.10.0
This function is no longer used. Use the :func:`.match_file` function with a
loop for better results.
Matches the files to the patterns.
*patterns* (:class:`~collections.abc.Iterable` of :class:`.Pattern`) contains
the patterns to use.
*files* (:class:`~collections.abc.Iterable` of :class:`str`) contains the
normalized file paths to be matched against *patterns*.
Returns the matched files (:class:`set` of :class:`str`).
)r'Úsetr(Úadd)r)r7rAÚ use_patternsr:r*s r!Ú match_filesrÍs\€ð.%-ÖJ˜5°·
±
Ñ0I’ÐJ€ÐJä“€Ø
ò€TÜ� ˜dÕ#Ø×Ñ�DÕðð ÐùòKs
…A—Acóü—|€t}|€J|«‚tj|«}|D]"}|j|tj
«}Œ$|j
d«r|dd}|S|j
d«r|dd}|S)a‚
Normalizes the file path to use the POSIX path separator (i.e., ``"/"``), and
make the paths relative (remove leading ``"/"``).
*file* (:class:`str` or :class:`os.PathLike`) is the file path.
*separators* (:class:`~collections.abc.Collection` of :class:`str`; or
:data:`None`) optionally contains the path separators to normalize. This does
not need to include the POSIX path separator (``"/"``), but including it will
not affect the results. Default is ``None`` for :data:`.NORMALIZE_PATH_SEPS`.
To prevent normalization, pass an empty container (e.g., an empty tuple
``()``).
Returns the normalized file path (:class:`str`).
Nú/rz./é)ÚNORMALIZE_PATH_SEPSrÚfspathÚreplaceÚ posixpathrÚ
startswith)r*Ú
separatorsÚ norm_filers r!Únormalize_filerŠîs˜€ð(ÐÜ"€*àÐÐ* 
Ó*Ðô—)‘)˜D“/€à ò4€SØ×Ñ ¤Y§]¡]Ó3�)ð4ð×јÔà˜˜ˆm€)ð Ðð ×ј4Ô à˜˜ˆm€)àÐr#zcpathspec.util.normalize_files() is deprecated. Use normalize_file() with a loop for better results.cóp—i}|D].}t||¬«}||vr||j|«Œ)|g||<Œ0|S)a±
.. version-deprecated:: 0.10.0
This function is no longer used. Use the :func:`.normalize_file` function
with a loop for better results.
Normalizes the file paths to use the POSIX path separator.
*files* (:class:`~collections.abc.Iterable` of :class:`str` or
:class:`os.PathLike`) contains the file paths to be normalized.
*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 a :class:`dict` mapping each normalized file path (:class:`str`) to
the original file paths (:class:`list` of :class:`str` or
:class:`os.PathLike`).
)rˆ)rŠr5)r7rˆÚ
norm_filesrr‰s r!Únormalize_filesr�sS€ð4)+€Ø
ò"€TܘT¨jÔ9€)Ø�*ÑØ
ˆiÑ×Ñ Õ%à ˜6€:ˆiÒð "ð Ðr#có—t|t«std|›d�«‚t|«std|›d�«‚|tvr|st |t|«‚|t|<y)aE
Registers the specified pattern factory.
*name* (:class:`str`) is the name to register the pattern factory under.
*pattern_factory* (:class:`~collections.abc.Callable`) is used to compile
patterns. It must accept an uncompiled pattern (:class:`str`) and return the
compiled pattern (:class:`.Pattern`).
*override* (:class:`bool` or :data:`None`) optionally is whether to allow
overriding an already registered pattern under the same name (:data:`True`),
instead of raising an :exc:`.AlreadyRegisteredError` (:data:`False`). Default
is :data:`None` for :data:`False`.
zname=z is not a string.zpattern_factory=rPN)r2rrSrRrÚAlreadyRegisteredError)rcÚpattern_factoryÚoverrides r!Úregister_patternr’=sk€ô& �4œÔÜ�U�T�IÐ.Ð/Ó0Ð0ä�Ô!ÜÐ%�_Ð(Ð(9Ð:Ó;Ð;àÔ Ñ ©Ü˜tÔ%9¸$Ñ%?Ó@Ð@à-Ô�dÒr#cóf‡—eZdZdZ dˆfd„ Zedd„«Zedd„«Zedd„«ZˆxZ S) r�z|
The :exc:`AlreadyRegisteredError` exception is raised when a pattern factory
is registered under a name already in use.
có&•—t‰|�||«y)zÜ
Initializes the :exc:`AlreadyRegisteredError` instance.
*name* (:class:`str`) is the name of the registered pattern.
*pattern_factory* (:class:`~collections.abc.Callable`) is the registered
pattern factory.
N©ÚsuperÚ__init__)Úselfrcr�Ú __class__s €r!r—zAlreadyRegisteredError.__init__bsø€ô�'Ñ�4˜Õ)r#có:—|j›d|j›d�S)ú4
*message* (:class:`str`) is the error message.
z+ is already registered for pattern factory=ú.)rcr�©r˜s r!ÚmessagezAlreadyRegisteredError.messageqs(€ð  ‡i�i€]Ð=Ø
×ÑИQð ðr#có —|jdS)zB
*name* (:class:`str`) is the name of the registered pattern.
r©Úargsr�s r!rczAlreadyRegisteredError.name{s€ð
�‰�1‰Ðr#có —|jdS)za
*pattern_factory* (:class:`~collections.abc.Callable`) is the registered
pattern factory.
rr r�s r!r�z&AlreadyRegisteredError.pattern_factory‚ó€ð
�‰�1‰Ðr#)rcrr�ú&Callable[[Union[str, bytes]], Pattern]ÚreturnÚNone©r¥r)r¥r¤)
Ú__name__Ú
__module__Ú __qualname__Ú__doc__r—Úpropertyržrcr�Ú
__classcell__©r™s@r!r�r�\seø„ñð
*à ð
*ð:ð
*ð õ
*ð òó ðð òó ðð  òó ôr#r�có|‡—eZdZdZ dˆfd„ Zedd„«Zedd„«Zedd„«Zedd„«Z ˆxZ
S) razM
The :exc:`RecursionError` exception is raised when recursion is detected.
có(•—t‰|�|||«y)a'
Initializes the :exc:`RecursionError` instance.
*real_path* (:class:`str`) is the real path that recursion was encountered
on.
*first_path* (:class:`str`) is the first path encountered for *real_path*.
*second_path* (:class:`str`) is the second path encountered for *real_path*.
Nr•)r˜rZr[r\r™s €r!r—zRecursionError.__init__�sø€ô �'Ñ�9˜j¨+Õ6r#có —|jdS)zx
*first_path* (:class:`str`) is the first path encountered for
:attr:`self.real_path <RecursionError.real_path>`.
rr r�s r!r[zRecursionError.first_path¢r£r#cóV—d|j›d|j›d|j›d�S)r›z
Real path z was encountered at z
and then rœrYr�s r!ržzRecursionError.messageªs:€ð �—‘Ð!Ð!5°d·o±oÐ5HðIØ×ÑÐ" !ð%ðr#có —|jdS)zV
*real_path* (:class:`str`) is the real path that recursion was
encountered on.
rr r�s r!rZzRecursionError.real_path´r£r#có —|jdS)zz
*second_path* (:class:`str`) is the second path encountered for
:attr:`self.real_path <RecursionError.real_path>`.
r‚r r�s r!r\zRecursionError.second_path¼r£r#)rZrr[rr\rr¥r¦r§) r¨r©rªr«r—r¬r[ržrZr\r­r®s@r!rara‹sƒø„ñð7à
ð7ðð7ðð 7ð
 õ 7ð$ òó ðð òó ðð òó ðð òó ôr#ra)Úfrozencó8—eZdZUdZdZded< ded< ded<y )
Ú CheckResultze
The :class:`CheckResult` class contains information about the file and which
pattern matched it.
)r*r'r,rr*úOptional[bool]r'z
Optional[int]r,N)r¨r©rªr«Ú __slots__Ú__annotations__©r#r!r·r·Ås4…ñð €ð ƒðð Óðð
Óðr#r·có—eZdZdZdZdd„Zy)r6z>
The :class:`.MatchDetail` class contains information about
©r)có—||_y)zÎ
Initialize the :class:`.MatchDetail` instance.
*patterns* (:class:`~collections.abc.Sequence` of :class:`.Pattern`)
contains the patterns that matched the file in the order they were encountered.
Nr½)r˜r)s r!r—zMatchDetail.__init__ís€ð€$„-ðr#N)r)zSequence[Pattern]r¥r¦)r¨r©rªr«r¹r—r»r#r!r6r6ås„ñð
€ô
r#r6cóV—eZdZdZdZ d d„Zd
d d„Zd
d d„Zd d„Zd
d
d„Z y)rgzP
The :class:`TreeEntry` class contains information about a file-system entry.
©Ú_lstatrcrÚ_statcóB—||_ ||_ ||_ ||_y)aM
Initialize the :class:`TreeEntry` instance.
*name* (:class:`str`) is the base name of the entry.
*path* (:class:`str`) is the relative path of the entry.
*lstat* (:class:`os.stat_result`) is the stat result of the direct entry.
*stat* (:class:`os.stat_result`) is the stat result of the entry,
potentially linked.
NrÀ)r˜rcrÚlstatrds r!r—zTreeEntry.__init__s:€ð(!&€$„+ðð€$„)ðð€$„)ðð $€$„*ðr#Ncó|—|€d}|r |jn |j}tj|j«S)a<
Get whether the entry is a directory.
*follow_links* (:class:`bool` or :data:`None`) is whether to follow symbolic
links. If this is :data:`True`, a symlink to a directory will result in
:data:`True`. Default is :data:`None` for :data:`True`.
Returns whether the entry is a directory (:class:`bool`).
T)rÂrÁrdÚS_ISDIRÚst_mode©r˜rIrss r!rzTreeEntry.is_dir-ó5€ðÐØ€<á(ˆd�jŠj¨d¯k©k€)Ü
�‰�i×'Ñ'Ó (Ð(r#có|—|€d}|r |jn |j}tj|j«S)aE