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Ïcãó²UdZddlmZddlZddlZddlZddlZddlZddlm Z m
Z
m Z m Z ddl
mZddlmZmZmZmZmZmZmZddlmZdd lmZmZeeej:efZed
e¬ «Z ed ed
¬«Z ede¬ «Z! ejDejFfDcgc]}|r|ejDk7r ee|«Œc}Z$ iZ%de&d< d0dZ' d1 d2dZ( d1 d3dZ) d4dZ*d5dZ+ed«d6d«Z, d6 d7dZ- d8dZ. d6 d9dZ/ d:dZ0d;dZ1d<dZ2ed« 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óbt|«}|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€Ø‡KK„MØ
Œbf‰fÑ€(àócóö|r9|D]3\}}|jŒ|j|«Œ%|j|fcSyd}d}|D]2\}}|jŒ|j|«Œ%|j}|}Œ4||fS)
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`).
NN©ÚincludeÚ
match_file)ÚpatternsÚfileÚ is_reversedÚindexÚpatternÚ out_includeÚ out_indexs r!Úcheck_match_filer0Xñ.ð"n€eˆ
‡o! g×&8Ñ&8¸Ó&>Ñ&JØ ?‰?˜ 
ð!%€+Ø!€)Ø òn€eˆWØ
‡o! g×&8Ñ&8¸Ó&>Ñ&JØ—//€KØð
Ðr#cóXt|t«r|n
t|«}i}|D]…}|jŒ|j |«}|jrO|D]I}||vr4|r||j
j
|«Œ(|||j
d<Œ;t|g«||<ŒKŒ||D]}||=ŒŒ‡|S)
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=ô,¬
Ô3‰U¼¸e»Ø(*€Øò€WØ ‡_ Ø—--  Ó*€<Ø
‡o‚oà ØØ ×Õ9à/6€| ×)¨!Ò,ä"-¨w¨iÓ"8€lñòˆØ ñð#ð( Ðr#cóft|«Dcgc]\}}|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ˆ
‡]ð ˆEÒó ðùó s-cóTt|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¸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úóAAÁAÁAc #óxKtjj||«}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‰GL‰L˜ GÓ ,€Ü G‰G× Ñ ˜ &€ð
Ø€$€x‚.ä °d¸8±nÐRYÔ‡jjÓð!D˜iàòD€hÜg‰gl‰l˜7 H§M¡MÓ2€8ð
بuÓ5€Jð ×ÑÔðØ €Ià‡oo l€oÔ H—MM 8¨Z¸Ó
& y°(¸DÀ(ÈLÓY××ÑÔ˜h×
H—MM 8¨Z¸Ó
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)
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¸¸È<Ó X×XúrWc #ó6Ktjj||«}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!ruruoèø€ô4
G‰GL‰L˜ GÓ ,€Ü G‰G× Ñ ˜ &€ð
Ø€$€x‚.ä °d¸8±nÐRYÔ‡jjÓð˜iàò€hÜg‰gl‰l˜7 H§M¡MÓ2€8à‡oo l€oÔ% Y°¸$ÀÈ,Ó×ÑÔà
ƒNâ ˜X×
ƒNñ÷ð.
ˆ(Xø÷ð.
ˆ(^üs=A0DÁ2AD
ÃDÃD
Ã$D
Ã5D
Ã< DÄD
Ä
DÄ
Dcót|S)
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ô ˜"r#cónd}|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Ø
_‰_ð r#z[pathspec.util.match_files() is deprecated. Use match_file() with a loop for better results.có¦|Dcgc]}|jŒ|Œ}}t«}|D] }t||«sŒ|j|«Œ"|Scc}w)
.. 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˜·
±
Ñ0I’ÐJ€ÐØ
ò€TÜ ˜dÕ×Ñðð ÐùòKs
AAcóü|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`).
/rz./é)ÚNORMALIZE_PATH_SEPSrÚfspathÚreplaceÚ posixpathrÚ
startswith)r*Ú
separatorsÚ norm_filers r!Únormalize_filerŠîs˜ð(ÐÜ"€*àÐÐ* 
Óô—)‘)˜D“/€à ò4€SØ×Ñ ¤Y§]¡]Ó3×јÔà˜˜ˆm€)ð Ðð ×ј4Ô à˜˜ˆm€)àÐr#zcpathspec.util.normalize_files() is deprecated. Use normalize_file() with a loop for better results.cópi}|D].}t||¬«}||vr||j|«Œ)|g||<Œ0|S)
.. 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ˆ)r5)r7rˆÚ
norm_filesrr‰s r!Únormalize_filesrsSð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ô& ÔÜUTÔÐ%(Ð(9ÐÔ Ñ ©Ü˜tÔ%9¸$Ñ%?Ór#cófeZdZdZ dˆfd Zedd«Zedd«Zedd«ZˆxZ S) rz|
The :exc:`AlreadyRegisteredError` exception is raised when a pattern factory
is registered under a name already in use.
có&t|||«y)
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.
ÚsuperÚ__init__)ÚselfrcrÚ __class__s €r!r—zAlreadyRegisteredError.__init__bsø€ô4˜Õ)r#có:|jd|jdS)ú4
*message* (:class:`str`) is the error message.
z+ is already registered for pattern factory=ú.)rcr©r˜s r!ÚmessagezAlreadyRegisteredError.messageqs(ð  ‡ii€]Ð
×ÑИQð ðr#có |jdS)zB
*name* (:class:`str`) is the name of the registered pattern.
r©Úargsrs r!rczAlreadyRegisteredError.name{sð
1‰Ðr#có |jdS)za
*pattern_factory* (:class:`~collections.abc.Callable`) is the registered
pattern factory.
rr rs r!rz&AlreadyRegisteredError.pattern_factoryóð
1‰Ðr#)rcrrú&Callable[[Union[str, bytes]], Pattern]ÚreturnÚNone©r))
Ú__name__Ú
__module__Ú __qualname__Ú__doc__r—ÚpropertyržrcrÚ
__classcell__©r™s@r!rr\seø„ñð
 ð

 õ
 òó ðð òó ðð  òó ôr#rcó|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 rs r!r[zRecursionError.first_path¢r#cóVd|jd|jd|jdS)rz
Real path z was encountered at z
and then rœrYrs 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 rs r!rZzRecursionError.real_path´r#có |jdS)zz
*second_path* (:class:`str`) is the second path encountered for
:attr:`self.real_path <RecursionError.real_path>`.
rr rs r!r\zRecursionError.second_path¼r#)rZrr[rr\r) r—r[rZr\r­s@r!raraø„ñð
ððð 
 õ 7ð$ òó ðð òó ðð òó ðð òó ôr#ra)Úfrozencó8eZdZUdZdZded< 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)Ú __slots__Ú__annotations__©r#r!Ås4ñð ð ƒðð Óðð
Óðr#cóeZdZdZdZddZy)r6z>
The :class:`.MatchDetail` class contains information about
©r)có||_y)
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!r6r6åsñð
ô
r#r6cóVeZdZdZdZ d dZd
d dZd
d dZd dZd
d
dZ 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)rdÚS_ISDIRÚst_mode©r˜rIrss r!rzTreeEntry.is_dir-ó5ðÐØ€<á(ˆdjŠj¨d¯k©k€)Ü
i×'Ó (Ð(r#có||d}|r |jn |j}tj|j«S)aE