
    jA                    "   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,dS )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dPdZdQdZdRdZdSdZdRdZdTdZ		 dUdVdZ
	 dUdWd"Z	 	 dXdYd*ZeeddddZd2                        Zeedddd[d4                        Zeedddd\d7                        Zeedddd]d9                        Zedddd^d<            Zed_dA            Z	 dUddBd`dGZ	 dUdadHZ	 dUddBdbdJZ	 	 dXddBdcdKZ edL          dddN            Z	 	 dXddBdedOZdS )fr   zd
	The :class:`PathSpec` class is a wrapper around a list of compiled
	:class:`.Pattern` instances.
	Nbackend_test_backend_factorypatterns3Union[Sequence[TPattern_co], Iterable[TPattern_co]]r(   "Union[BackendNamesHint, str, None]r)   r   returnNonec                   t          |t                    r|}nt          |          }|d}t          t          |          }| ||          }n|                     ||          }|| _        	 || _        	 || _        dS )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_namer*   )selfr*   r(   r)   use_patternsbackend_nameuse_backends          [/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/pathspec/pathspec.py__init__zPathSpec.__init__=   s    & (## !<<x..<_7&00,&&&|44;;##L,??;'$-
 *6$ *6$-     strc                @    | j         j         d| j        d| j        dS )z7
		Returns a debug representation of this path-spec.
		z
(patterns=z
, backend=))	__class____name__r*   r5   r6   s    r:   __repr__zPathSpec.__repr__o   s-     N#	a	at}	a	a$J\	a	a	aar<   r6   r   otherc                    t          |t                    r*|                     g | j        |j        | j                  S t
          S )zn
		Combines the :attr:`self.patterns <.PathSpec.patterns>` patterns from two
		:class:`PathSpec` instances.
		)r(   )r1   r   r@   r*   r5   NotImplementedr6   rD   s     r:   __add__zPathSpec.__add__u   sD    
 x   
..:4=:5>:DDV.
W
WW
r<   objectboolc                    t          |t                    r3t          | 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    V  d S N ).0abs      r:   	<genexpr>z"PathSpec.__eq__.<locals>.<genexpr>   s*      11Aa1f111111r<   )r1   r   r   r*   allrF   )r6   rD   paired_patternss      r:   __eq__zPathSpec.__eq__   sL    
 x    ???
11111
1
11
r<   c                    t          |t                    r<g | j        |j        | _        |                     | j        | j                  | _        | S t          S )zn
		Adds the :attr:`self.patterns <.PathSpec.patterns>` from *other*
		(:class:`PathSpec`) to this instance.
		)r1   r   r*   r3   r5   r4   rF   rG   s     r:   __iadd__zPathSpec.__iadd__   sR    
 x   4T]4U^44=%%d&8$-HH4=
;
r<   intc                *    t          | j                  S )zp
		Returns the number of :attr:`self.patterns <.PathSpec.patterns>` this
		path-spec contains (:class:`int`).
		)lenr*   rB   s    r:   __len__zPathSpec.__len__   s    
 
T]		r<   filer"   
separatorsOptional[Collection[str]]CheckResult[TStrPath]c                ~    t          ||          }| 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%   r4   
match_filer   )r6   r\   r]   	norm_fileincludeindexs         r:   
check_filezPathSpec.check_file   s>    " T:..)=++I66.'5	T7E	*	**r<   filesIterable[TStrPath]Iterator[CheckResult[TStrPath]]c              #     K   t          |          st          d|d          |D ]B}t          ||          }| j                            |          \  }}t          |||          V  CdS )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%   r4   ra   r   )r6   rf   r]   	orig_filerb   rc   rd   s          r:   check_fileszPathSpec.check_files   s      & 
e		 ;	9E999	:	:: 0 0ii449M,,Y77>7E	Y	/	/////0 0r<   rootr   on_error#Optional[Callable[[OSError], None]]follow_linksOptional[bool]Iterator[CheckResult[str]]c              #  n   K   t          j        |||          }|                     |          E d{V  dS )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`).
		rp   rr   N)r   iter_tree_filesrn   )r6   ro   rp   rr   rf   s        r:   check_tree_fileszPathSpec.check_tree_files   sK      < 
th\
R
R
R%e$$$$$$$$$$$r<   clstype[PathSpec]pattern_factoryLiteral['gitignore']linesIterable[AnyStr]PathSpec[GitIgnoreBasicPattern]c                   d S rM   rN   ry   r{   r}   r(   r)   s        r:   
from_lineszPathSpec.from_lines   	     #r<   PathSpec[Pattern]c                   d S rM   rN   r   s        r:   r   zPathSpec.from_lines   r   r<   type[TPattern]PathSpec[TPattern]c                   d S rM   rN   r   s        r:   r   zPathSpec.from_lines  r   r<   Callable[[AnyStr], TPattern]c                   d S rM   rN   r   s        r:   r   zPathSpec.from_lines  r   r<   
type[Self]6Union[str, type[Pattern], Callable[[AnyStr], Pattern]]c               "   t          |t                    rt          j        |          n%t	          |          r|nt          d|d          t          |          st          d|d          fd|D             } | |||          }|S )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:rk   c                *    g | ]}| |          S rN   rN   )rO   _PathSpec__lineuse_factorys     r:   
<listcomp>z'PathSpec.from_lines.<locals>.<listcomp>F  s(    @@@f@kk&!!@@@r<   r'   )r1   r=   r   lookup_patterncallablerl   r$   )ry   r{   r}   r(   r)   r*   r6   r   s          @r:   r   zPathSpec.from_lines  s    < %% L$_55;;   L ;;	JoJJJ	K	KK	e		 ;	9E999	:	::@@@@@@@(	Xw>S	T	T	T$	+r<   namer   Sequence[Pattern]r   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   )r   r*   s     r:   r3   zPathSpec._make_backendJ  s    $ 
tX	.	..r<   negateentriesIterable[TreeEntry]r   Iterator[TreeEntry]c             #     K   t          |          st          d|d          |D ]?}t          |j        |          }| j                            |          \  }}|r| }|r|V  @dS )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:rk   N)r$   rl   r%   pathr4   ra   )r6   r   r]   r   entryrb   rc   _indexs           r:   match_entrieszPathSpec.match_entries^  s      2 
g		 ?	=g===	>	>>  eej*559]--i88?7F kG 
KKK r<   c                z    t          ||          }| 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%   r4   ra   rJ   )r6   r\   r]   rb   rc   r   s         r:   ra   zPathSpec.match_file  s8    " T:..)M,,Y77/'6	gr<   Iterator[TStrPath]c             #     K   t          |          st          d|d          |D ]:}t          ||          }| j                            |          \  }}|r| }|r|V  ;dS )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`).
		rj   rk   N)r$   rl   r%   r4   ra   )r6   rf   r]   r   rm   rb   rc   r   s           r:   match_fileszPathSpec.match_files  s      4 
e		 ;	9E999	:	::  ii449]--i88?7F kG 
OOO r<   c             #  r   K   t          j        |||          }|                     ||          E d{V  dS )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`).
		rv   r   N)r   iter_tree_entriesr   )r6   ro   rp   rr   r   r   s         r:   match_tree_entrieszPathSpec.match_tree_entries  sQ      @ "4(VVV'77777777777r<   zEPathSpec.match_tree() is deprecated. Use .match_tree_files() instead.Iterator[str]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)r6   argskws      r:   
match_treezPathSpec.match_tree  s     
		+	+	++r<   c             #  r   K   t          j        |||          }|                     ||          E d{V  dS )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`).
		rv   r   N)r   rw   r   )r6   ro   rp   rr   r   rf   s         r:   r   zPathSpec.match_tree_files  sP      > 
th\
R
R
R%eF33333333333r<   )r*   r+   r(   r,   r)   r   r-   r.   )r-   r=   )r6   r   rD   r   r-   r   )rD   rI   r-   rJ   )r-   rX   rM   )r\   r"   r]   r^   r-   r_   )rf   rg   r]   r^   r-   rh   )NN)ro   r   rp   rq   rr   rs   r-   rt   )ry   rz   r{   r|   r}   r~   r(   r,   r)   r   r-   r   )ry   rz   r{   r=   r}   r~   r(   r,   r)   r   r-   r   )ry   rz   r{   r   r}   r~   r(   r,   r)   r   r-   r   )ry   rz   r{   r   r}   r~   r(   r,   r)   r   r-   r   )ry   r   r{   r   r}   r~   r(   r,   r)   r   r-   r   )r   r   r*   r   r-   r   )r   r   r]   r^   r   rs   r-   r   )r\   r   r]   r^   r-   rJ   )rf   rg   r]   r^   r   rs   r-   r   )
ro   r   rp   rq   rr   rs   r   rs   r-   r   )r-   r   )
ro   r   rp   rq   rr   rs   r   rs   r-   r   )rA   
__module____qualname____doc__r;   rC   rH   rU   rW   r[   re   rn   rx   r   classmethodr   staticmethodr3   r   ra   r   r   r   r   r   rN   r<   r:   r   r   7   s[         15370 0 0 0 0 0db b b b   	 	 	 	
 
 
 
    +/+ + + + +0 +/0 0 0 0 0< 37!%	% % % % %B  1537     + (  1537     + (  1537     + (  1537     + (  1537) ) ) ) ) +)V / / / ,/, +/$
  $ $ $ $ $ $R +/    0 +/%
  % % % % % %T 37!%	!8  !8 !8 !8 !8 !8 !8H *I , , , , 37!%	 4   4  4  4  4  4  4  4  4r<   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   rN   r<   r:   <module>r      sk    # " " " " "           
                         wvZ(((
                    
 
 
 
 
 
                               X4 X4 X4 X4 X4w{# X4 X4 X4 X4 X4r<   