
    h3                         d Z ddl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mZ ddlmZ ddlmZ ddlmZmZmZmZmZmZmZ  ed	d
      Z	  G d d
e      Zy)zR
This module provides an object oriented interface for pattern matching of files.
    )
Collection)zip_longest)	AnyStrCallabler   IterableIteratorOptionalTypeTypeVarUnion   )util)Pattern)CheckResultStrPathTStrPath	TreeEntry_filter_check_patterns_is_iterablenormalize_fileSelfPathSpec)boundc                      e Zd ZdZdee   ddfdZdedefdZ	de
fdZd	edd defd
Zd	edd defdZ	 d!dedeee      dee   fdZ	 d!dee   deee      deee      fdZ	 	 d"dedeeegdf      dee   deee      fdZedee   deeeegef   f   dee   defd       Z	 d!dddee    deee      dee   dee    fdZ! e"e#jH                        Z%	 	 d!dedeee      defdZ&	 d!dddee   deee      dee   dee   fdZ'	 	 d"dddedeeegdf      dee   dee   dee    f
dZ(	 	 d"dddedeeegdf      dee   dee   dee   f
d Z)e)Z*y)#r   zd
	The :class:`PathSpec` class is a wrapper around a list of compiled
	:class:`.Pattern` instances.
	patternsreturnNc                 H    t        |t              st        |      }|| _        y)z
		Initializes the :class:`PathSpec` instance.

		*patterns* (:class:`~collections.abc.Collection` or :class:`~collections.abc.Iterable`)
		yields each compiled pattern (:class:`.Pattern`).
		N)
isinstanceCollectionTypelistr   )selfr   s     D/var/www/html/immo/lib/python3.12/site-packages/pathspec/pathspec.py__init__zPathSpec.__init__-   s#     
Hn	-8n8'/$-    otherc                     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:`~PathSpec.patterns` attributes.
		c              3   ,   K   | ]  \  }}||k(    y wN ).0abs      r"   	<genexpr>z"PathSpec.__eq__.<locals>.<genexpr>D   s     1Aa1f1s   )r   r   r   r   allNotImplemented)r!   r%   paired_patternss      r"   __eq__zPathSpec.__eq__=   s9    
 x  ??
11
11
r$   c                 ,    t        | j                        S )zW
		Returns the number of compiled patterns this path-spec contains
		(:class:`int`).
		)lenr   )r!   s    r"   __len__zPathSpec.__len__H   s    
 
T]]	r$   r!   c                 ~    t        |t              r(| j                  | j                  |j                  z         S t        S )z]
		Combines the :attr:`Pathspec.patterns` patterns from two
		:class:`PathSpec` instances.
		)r   r   	__class__r   r/   r!   r%   s     r"   __add__zPathSpec.__add__O   s0    
 x 
..7
88
r$   c                 p    t        |t              r!| xj                  |j                  z  c_        | S t        S )zi
		Adds the :attr:`Pathspec.patterns` patterns from one :class:`PathSpec`
		instance to this instance.
		)r   r   r   r/   r7   s     r"   __iadd__zPathSpec.__iadd__Y   s+    
 x ==ENN"=
;
r$   file
separatorsc                     t        ||      }| j                  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:`~pathspec.util.normalize_file` for more information.

		Returns the file check result (:class:`~pathspec.util.CheckResult`).
		)r   _match_file	enumerater   r   )r!   r;   r<   	norm_fileincludeindexs         r"   
check_filezPathSpec.check_filed   s>    " T:.)##Idmm$<iH.'5	T7E	**r$   filesc              #      K   t        |      st        d|d      t        | j                        }|D ]2  }t	        ||      }| j                  ||      \  }}t        |||       4 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:`~pathspec.util.normalize_file` for more information.

		Returns an :class:`~collections.abc.Iterator` yielding each file check
		result (:class:`~pathspec.util.CheckResult`).
		files: is not an iterable.N)r   	TypeErrorr   r   r   r>   r   )r!   rD   r<   use_patterns	orig_filer@   rA   rB   s           r"   check_fileszPathSpec.check_filesy   ss     & 
e		VE9$89	::'6, 0ii49$$\9=>7E	Y	//0s   A(A*rooton_errorfollow_linksc              #   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:`~pathspec.util.CheckResult`).
		rM   rN   N)r   iter_tree_filesrK   )r!   rL   rM   rN   rD   s        r"   check_tree_fileszPathSpec.check_tree_files   s0     < 

th\
R%e$$$s   -757clspattern_factorylinesc                     t        |t              rt        j                  |      }t	        |      st        d|d      t        |      st        d|d      |D cg c]  }|s ||       }} | |      S c c}w )ai  
		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`.

		Returns the :class:`PathSpec` instance.
		zpattern_factory:z is not callable.zlines:rG   )r   strr   lookup_patterncallablerH   r   )rS   rT   rU   liner   s        r"   
from_lineszPathSpec.from_lines   s    * %((9?	/	"	%o%88IJ	KK	e		VE9$89	::05>od#>(>	X ?s   A:&
A:negateentriesr]   c             #      K   t        |      st        d|d      t        | j                        }|D ]9  }t	        |j
                  |      }| j                  ||      \  }}|r| }|s6| ; yw)a  
		Matches the entries to this path-spec.

		*entries* (:class:`~collections.abc.Iterable` of :class:`~pathspec.util.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:`~pathspec.util.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:`~pathspec.util.TreeEntry`).
		zentries:rG   N)r   rH   r   r   r   pathr>   )	r!   r^   r<   r]   rI   entryr@   rA   _indexs	            r"   match_entrieszPathSpec.match_entries   sz     2 
g		Xg[(<=	>>'6, eejj*59%%lI>?7FkG
Ks   A'A1*A1c                     t        ||      }| j                  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:`~pathspec.util.normalize_file` for more information.

		Returns :data:`True` if *file* matched; otherwise, :data:`False`.
		)r   r>   r?   r   bool)r!   r;   r<   r@   rA   rb   s         r"   
match_filezPathSpec.match_file  s9    " T:.)$$Yt}}%=yI/'6	gr$   c             #      K   t        |      st        d|d      t        | j                        }|D ]/  }t	        ||      }| j                  ||      \  }}|r| }|s,| 1 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:`~pathspec.util.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`).
		rF   rG   N)r   rH   r   r   r   r>   )	r!   rD   r<   r]   rI   rJ   r@   rA   rb   s	            r"   match_fileszPathSpec.match_files  sv     4 
e		VE9$89	::'6, ii49%%lI>?7FkG
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`).
		rP   r\   N)r   iter_tree_entriesrc   )r!   rL   rM   rN   r]   r^   s         r"   match_tree_entrieszPathSpec.match_tree_entriesB  s6     @ ""4(V'777   /979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`).
		rP   r\   N)r   rQ   rh   )r!   rL   rM   rN   r]   rD   s         r"   match_tree_fileszPathSpec.match_tree_filese  s6     @ 

th\
R%eF333rl   r(   )NN)+__name__
__module____qualname____doc__r   r   r#   objectre   r1   intr4   r   r8   r:   r   r	   r   rW   r   rC   r   rK   r   r   OSErrorrR   classmethodr
   r   r   r[   r   rc   staticmethodr   check_match_filer>   rf   rh   rk   rn   
match_treer)   r$   r"   r   r   '   sH   
hw/ D  	 	D 	c 4 
 t 	D 	 	 	 +/++ z#'+ (	+0 +/0	(	0 z#'0 {8$%	0> 37!%	%% Xwio./% 	%
 {3 %B Dzhx'899: 
&	 	 F +/%
  %I% z#'%
 4.% y%N D112 +/ z#' 	0 +/&
  &	'	& z#'&
 4.& w&V 37!%	!8  !8!8 Xwio./!8 	!8 4.!8 y!8L 37!%	!4  !4!4 Xwio./!4 	!4 4.!4 sm!4J r$   N)rr   collections.abcr   r   	itertoolsr   typingr   r   r   r   r	   r
   r   r    r   patternr   r   r   r   r   r   r   r   r   rs   r   r)   r$   r"   <module>r      s]   	 	 	 
   vZ(cv cr$   