Ë
    hKêjüA  ã                  ó  — d Z ddlmZ ddlmZmZmZmZ ddlm	Z	 ddl
mZmZmZmZmZmZmZmZ  edd¬«      Z	 dd	lmZ dd
lmZmZmZ ddlmZ ddlmZ ddlmZ ddl m!Z!m"Z" ddl#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+  G d„ de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                  ó”  — e Zd ZdZdddœ	 	 	 	 	 	 	 dd„Zdd„Zdd„Zdd„Zdd„Zdd	„Z		 d 	 	 	 	 	 d!d
„Z
	 d 	 	 	 	 	 d"d„Z	 	 d#	 	 	 	 	 	 	 d$d„Zeedddœ	 	 	 	 	 	 	 	 	 	 	 d%d„«       «       Zeedddœ	 	 	 	 	 	 	 	 	 	 	 d&d„«       «       Zeedddœ	 	 	 	 	 	 	 	 	 	 	 d'd„«       «       Zeedddœ	 	 	 	 	 	 	 	 	 	 	 d(d„«       «       Zedddœ	 	 	 	 	 	 	 	 	 	 	 d)d„«       Ze	 	 	 	 	 	 d*d„«       Z	 d ddœ	 	 	 	 	 	 	 d+d„Z	 d 	 	 	 	 	 d,d„Z	 d ddœ	 	 	 	 	 	 	 d-d„Z	 	 d#ddœ	 	 	 	 	 	 	 	 	 d.d„Z ed«      d/d„«       Z	 	 d#ddœ	 	 	 	 	 	 	 	 	 d0d„Zy)1r   zd
	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}t        t        |«      }|�	 ||«      }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   Úlistr   r   Ú_make_backendÚ_backendÚ_backend_nameÚpatterns)Úselfr1   r(   r)   Úuse_patternsÚbackend_nameÚuse_backends          úV/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/pathspec/pathspec.pyÚ__init__zPathSpec.__init__=   s~   € ô& �œ(Ô#Ø�<ä�x“.€<à€_Ø€7äÔ&¨Ó0€,ØÐ&Ù& |Ó4�;à×#Ñ# L°,Ó?€;à'€$„-ðð
 *6€$Ôðð *6€$„-ðó    c                óh   — | j                   j                  › d| j                  ›d| j                  ›d�S )z7
		Returns a debug representation of this path-spec.
		z
(patterns=z
, backend=ú))Ú	__class__Ú__name__r1   r0   ©r2   s    r6   Ú__repr__zPathSpec.__repr__o   s5   € ð �N‰N×#Ñ#Ð$ J¨t¯}©}Ð.?¸zÈ$×J\ÑJ\ÐI_Ð_`Ð	aÐar8   c                ó˜   — t        |t        «      r5| j                  g | j                  ¢|j                  ¢| j                  ¬«      S t
        S )zn
		Combines the :attr:`self.patterns <.PathSpec.patterns>` patterns from two
		:class:`PathSpec` instances.
		)r(   )r,   r   r;   r1   r0   ÚNotImplemented©r2   Úothers     r6   Ú__add__zPathSpec.__add__u   s@   € ô
 �”xÔ Ø
�.‰.Ð:˜4Ÿ=™=Ð:¨5¯>©>Ð:ÀD×DVÑDVˆ.Ó
WÐWä
Ðr8   c                ó’   — t        |t        «      r2t        | j                  |j                  «      }t	        d„ |D «       «      S t
        S )z—
		Tests the equality of this path-spec with *other* (:class:`PathSpec`) by
		comparing their :attr:`self.patterns <.PathSpec.patterns>` attributes.
		c              3  ó,   K  — | ]  \  }}||k(  –— Œ y ­w©N© )Ú.0ÚaÚbs      r6   ú	<genexpr>z"PathSpec.__eq__.<locals>.<genexpr>†   s   è ø€ Ò1™˜˜Aˆa�1�fÑ1ùs   ‚)r,   r   r   r1   Úallr@   )r2   rB   Úpaired_patternss      r6   Ú__eq__zPathSpec.__eq__   s9   € ô
 �”xÔ Ü  §¡°·±Ó?€?Ü
Ñ1 Ô1Ó
1Ð1ä
Ðr8   c                óÆ   — t        |t        «      rLg | j                  ¢|j                  ¢| _        | j                  | j                  | j                  «      | _        | S t        S )zn
		Adds the :attr:`self.patterns <.PathSpec.patterns>` from *other*
		(:class:`PathSpec`) to this instance.
		)r,   r   r1   r.   r0   r/   r@   rA   s     r6   Ú__iadd__zPathSpec.__iadd__Š   sP   € ô
 �”xÔ Ø4�T—]‘]Ð4 U§^¡^Ð4€4„=Ø×%Ñ% d×&8Ñ&8¸$¿-¹-ÓH€4„=Ø
€;ä
Ðr8   c                ó,   — t        | j                  «      S )zp
		Returns the number of :attr:`self.patterns <.PathSpec.patterns>` this
		path-spec contains (:class:`int`).
		)Úlenr1   r=   s    r6   Ú__len__zPathSpec.__len__–   s   € ô
 
ˆT�]‰]Ó	Ðr8   c                óp   — t        ||«      }| j                  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 <.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_filezPathSpec.check_file�   s7   € ô" ˜T :Ó.€)Ø—=‘=×+Ñ+¨IÓ6�.€'ˆ5Ü	�T˜7 EÓ	*Ð*r8   c              #  óÀ   K  — t        |«      st        d|›d�«      ‚|D ];  }t        ||«      }| j                  j	                  |«      \  }}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/   rU   r   )r2   ÚfilesrW   Ú	orig_filerX   rY   rZ   s          r6   Úcheck_fileszPathSpec.check_files²   sg   è ø€ ô& 
�eÔ	Ü	�V˜E˜9Ð$8Ð9Ó	:Ð:àò 0€iÜ˜i¨Ó4€9Ø—M‘M×,Ñ,¨YÓ7�>€7ˆEÜ	�Y ¨Ó	/Ó/ñ0ùs   ‚AAc              #  ór   K  — t        j                  |||¬«      }| j                  |«      E d{  –—†  y7 Œ­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   Úrootre   rf   r`   s        r6   Úcheck_tree_fileszPathSpec.check_tree_filesÍ   s0   è ø€ ô< ×
Ñ
˜t¨hÀ\Ô
R€%Ø×Ñ˜eÓ$×$Ò$ús   ‚-7¯5°7c                ó   — y rF   rG   ©ÚclsÚpattern_factoryÚlinesr(   r)   s        r6   Ú
from_lineszPathSpec.from_linesî   ó   € ð r8   c                ó   — y rF   rG   rk   s        r6   ro   zPathSpec.from_linesú   rp   r8   c                ó   — y rF   rG   rk   s        r6   ro   zPathSpec.from_lines  rp   r8   c                ó   — y rF   rG   rk   s        r6   ro   zPathSpec.from_lines  rp   r8   c               ó  — t        |t        «      rt        j                  |«      }nt	        |«      r|}nt        d|›d�«      ‚t        |«      st        d|›d�«      ‚|D �cg c]  }|sŒ ||«      ‘Œ }} | |||¬«      }|S c c}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.
		zpattern_factory:z is not callable.zlines:r^   r'   )r,   Ústrr   Úlookup_patternÚcallabler_   r$   )	rl   rm   rn   r(   r)   Úuse_factoryÚ_PathSpec__liner1   r2   s	            r6   ro   zPathSpec.from_lines  s“   € ô< �¤Ô%Ü×$Ñ$ _Ó5�;Ü�Ô Ø �;ä	Ð% oÐ%8Ð8IÐJÓ	KÐKä	�eÔ	Ü	�V˜E˜9Ð$8Ð9Ó	:Ð:à05Ö@ fº‰k˜&Õ!Ð@€(Ð@Ù	ˆX˜wÐ>SÔ	T€$Ø	€+ùò As   Á"BÁ*
Bc                ó   — 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   )Únamer1   s     r6   r.   zPathSpec._make_backendJ  s   € ô$ 
˜t XÓ	.Ð.r8   ©Únegatec             #  óÎ   K  — t        |«      st        d|›d�«      ‚|D ]B  }t        |j                  |«      }| j                  j                  |«      \  }}|r| }|sŒ?|–— ŒD y­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`).
		zentries:r^   N)r$   r_   r%   Úpathr/   rU   )r2   ÚentriesrW   r}   ÚentryrX   rY   Ú_indexs           r6   Úmatch_entrieszPathSpec.match_entries^  sn   è ø€ ô2 
�gÔ	Ü	�X˜g˜[Ð(<Ð=Ó	>Ð>àò €eÜ˜eŸj™j¨*Ó5€9Ø—]‘]×-Ñ-¨iÓ8�?€7ˆFáØˆk€GâØ
ƒKñùs   ‚AA%ÁA%c                ól   — t        ||«      }| j                  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 <.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)r2   rV   rW   rX   rY   r‚   s         r6   rU   zPathSpec.match_file„  s2   € ô" ˜T :Ó.€)Ø—M‘M×,Ñ,¨YÓ7�/€'ˆ6Ü	ˆg‹Ðr8   c             #  óº   K  — t        |«      st        d|›d�«      ‚|D ]8  }t        ||«      }| j                  j	                  |«      \  }}|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   )r2   r`   rW   r}   ra   rX   rY   r‚   s           r6   Úmatch_fileszPathSpec.match_files™  sj   è ø€ ô4 
�eÔ	Ü	�V˜E˜9Ð$8Ð9Ó	:Ð:àò €iÜ˜i¨Ó4€9Ø—]‘]×-Ñ-¨iÓ8�?€7ˆFáØˆk€GâØ
ƒOñùs   ‚AAÁAc             #  óv   K  — t        j                  |||¬«      }| j                  ||¬«      E d{  –—†  y7 Œ­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`).
		rd   r|   N)r   Úiter_tree_entriesrƒ   )r2   rh   re   rf   r}   r€   s         r6   Úmatch_tree_entrieszPathSpec.match_tree_entriesÀ  s6   è ø€ ô@ ×"Ñ" 4°(ÈÔV€'Ø×Ñ °ÐÓ7×7Ò7úó   ‚/9±7²9zEPathSpec.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_treezPathSpec.match_treeä  s   € ð 
ˆ×	Ñ	 Ð	+¨Ñ	+Ð+r8   c             #  óv   K  — t        j                  |||¬«      }| j                  ||¬«      E d{  –—†  y7 Œ­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`).
		rd   r|   N)r   rg   r‡   )r2   rh   re   rf   r}   r`   s         r6   r�   zPathSpec.match_tree_filesï  s5   è ø€ ô> ×
Ñ
˜t¨hÀ\Ô
R€%Ø×Ñ˜e¨FÐÓ3×3Ò3úr‹   )r1   z3Union[Sequence[TPattern_co], Iterable[TPattern_co]]r(   ú"Union[BackendNamesHint, str, None]r)   r   ÚreturnÚNone)r“   ru   )r2   r   rB   r   r“   r   )rB   Úobjectr“   r…   )r“   ÚintrF   )rV   r"   rW   úOptional[Collection[str]]r“   zCheckResult[TStrPath])r`   úIterable[TStrPath]rW   r—   r“   zIterator[CheckResult[TStrPath]])NN)rh   r   re   ú#Optional[Callable[[OSError], None]]rf   úOptional[bool]r“   zIterator[CheckResult[str]])rl   útype[PathSpec]rm   zLiteral['gitignore']rn   úIterable[AnyStr]r(   r’   r)   r   r“   zPathSpec[GitIgnoreBasicPattern])rl   r›   rm   ru   rn   rœ   r(   r’   r)   r   r“   zPathSpec[Pattern])rl   r›   rm   ztype[TPattern]rn   rœ   r(   r’   r)   r   r“   úPathSpec[TPattern])rl   r›   rm   zCallable[[AnyStr], TPattern]rn   rœ   r(   r’   r)   r   r“   r�   )rl   z
type[Self]rm   z6Union[str, type[Pattern], Callable[[AnyStr], Pattern]]rn   rœ   r(   r’   r)   r   r“   r   )r{   r   r1   zSequence[Pattern]r“   r   )r€   zIterable[TreeEntry]rW   r—   r}   rš   r“   úIterator[TreeEntry])rV   r   rW   r—   r“   r…   )r`   r˜   rW   r—   r}   rš   r“   zIterator[TStrPath])
rh   r   re   r™   rf   rš   r}   rš   r“   rž   )r“   úIterator[str])
rh   r   re   r™   rf   rš   r}   rš   r“   rŸ   )r<   Ú
__module__Ú__qualname__Ú__doc__r7   r>   rC   rN   rP   rS   r[   rb   ri   r   Úclassmethodro   Ústaticmethodr.   rƒ   rU   r‡   rŠ   r   r�   r�   rG   r8   r6   r   r   7   s  „ ñð 15Ø37ñ0à?ð0ð .ð	0ð
 1ð0ð ó0ódbóó	ó
óð +/ð+àð+ð (ð+ð ó	+ð0 +/ð0à	ð0ð (ð0ð &ó	0ð< 37Ø!%ð	%àð%ð 0ð%ð ð	%ð
 !ó%ðB Øð 15Ø37ñØðà'ðð 
ðð
 .ðð 1ðð &òó ó ðð Øð 15Ø37ñØðàðð 
ðð
 .ðð 1ðð òó ó ðð Øð 15Ø37ñØðà!ðð 
ðð
 .ðð 1ðð òó ó ðð Øð 15Ø37ñØðà/ðð 
ðð
 .ðð 1ðð òó ó ðð ð 15Ø37ñ)Øð)àIð)ð 
ð)ð
 .ð)ð 1ð)ð ò)ó ð)ðV ð/Øð/àð/ð ò/ó ð/ð, +/ð$ð
  ñ$àð$ð (ð$ð
 ð$ð ó$ðR +/ðàðð (ðð ó	ð0 +/ð%ð
  ñ%à	ð%ð (ð%ð
 ð%ð ó%ðT 37Ø!%ð	!8ð  ñ!8àð!8ð 0ð!8ð ð	!8ð ð!8ð ó!8ñH ØIóò,óð,ð 37Ø!%ð	 4ð  ñ 4àð 4ð 0ð 4ð ð	 4ð ð 4ð ô 4r8   N)-r¢   Ú
__future__r   Úcollections.abcr   r   r   r   Ú	itertoolsr   Útypingr	   r
   r   r   r   r   r   r   r   Úpathspecr   Úpathspec.backendr   r   r   Úpathspec._backends.aggr   Úpathspec.patternr   Ú!pathspec.patterns.gitignore.basicr   Úpathspec._typingr   r   Úpathspec.utilr   r   r    r!   r"   r#   r$   r%   r   rG   r8   r6   ú<module>r°      s…   ðñõ #÷ó õ
÷÷ ó ñ ˆv˜ZÔ(€ðõ
 ÷ñ õõ
õ÷÷÷ ó ôX4ˆw�{Ñ#õ X4r8   