§
    ïyIfÙ3  ã                   óÂ   — 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dS )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#j$        ¦  «        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*dS )#r   zd
	The :class:`PathSpec` class is a wrapper around a list of compiled
	:class:`.Pattern` instances.
	ÚpatternsÚreturnNc                 ó\   — t          |t          ¦  «        st          |¦  «        }|| _        dS )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     úE/var/www/piapp/venv/lib/python3.11/site-packages/pathspec/pathspec.pyÚ__init__zPathSpec.__init__-   s2   € õ 
�H�nÑ	-Ô	-ð Ý�8‰nŒn€8à'/€$„-ðð ó    Úotherc                 ó    — 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:`~PathSpec.patterns` attributes.
		c              3   ó(   K  — | ]\  }}||k    V — Œd S ©N© )Ú.0ÚaÚbs      r"   ú	<genexpr>z"PathSpec.__eq__.<locals>.<genexpr>D   s*   è è € Ð1Ð1™˜˜Aˆa�1ŠfÐ1Ð1Ð1Ð1Ð1Ð1r$   )r   r   r   r   ÚallÚNotImplemented)r!   r%   Úpaired_patternss      r"   Ú__eq__zPathSpec.__eq__=   sL   € õ
 �•xÑ Ô ð Ý  ¤°´Ñ?Ô?€?Ý
Ð1Ð1 Ð1Ñ1Ô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        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   s7   € õ
 �•xÑ Ô ð Ø
�.Š.˜œ¨¬Ñ7Ñ
8Ô
8Ð8å
Ðr$   c                 óh   — 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   s3   € õ
 �•xÑ Ô ð Ø€=„=�E”NÑ"€=„=Ø
€;å
Ðr$   ÚfileÚ
separatorsc                 óš   — t          ||¦  «        }|                      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   sH   € õ" ˜T :Ñ.Ô.€)Ø×#Ò#¥I¨d¬mÑ$<Ô$<¸iÑHÔH�.€'ˆ5Ý	�T˜7 EÑ	*Ô	*Ð*r$   Úfilesc              #   óø   K  — t          |¦  «        st          d|›d�¦  «        ‚t          | j        ¦  «        }|D ]>}t	          ||¦  «        }|                      ||¦  «        \  }}t          |||¦  «        V — Œ?d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:`~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   s�   è è € õ& 
�eÑ	Ô	ð ;Ý	Ð9˜EÐ9Ð9Ð9Ñ	:Ô	:Ð:å'¨¬Ñ6Ô6€,Øð 0ð 0€iÝ˜i¨Ñ4Ô4€9Ø×$Ò$ \°9Ñ=Ô=�>€7ˆEÝ	�Y ¨Ñ	/Ô	/Ð/Ð/Ð/Ð/ð0ð 0r$   ÚrootÚon_errorÚfollow_linksc              #   ó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:`~pathspec.util.CheckResult`).
		©rM   rN   N)r   Úiter_tree_filesrK   )r!   rL   rM   rN   rD   s        r"   Úcheck_tree_fileszPathSpec.check_tree_files•   sK   è è € õ< Ô
˜t¨hÀ\Ð
RÑ
RÔ
R€%Ø×Ò˜eÑ$Ô$Ð$Ð$Ð$Ð$Ð$Ð$Ð$Ð$Ð$r$   ÚclsÚpattern_factoryÚlinesc                 ó  ‡— t          ‰t          ¦  «        rt          j        ‰¦  «        Št	          ‰¦  «        st          d‰›d�¦  «        ‚t          |¦  «        st          d|›d�¦  «        ‚ˆfd„|D ¦   «         } | |¦  «        S )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   c                 ó*   •— g | ]}|¯ ‰|¦  «        ‘ŒS r)   r)   )r*   ÚlinerT   s     €r"   ú
<listcomp>z'PathSpec.from_lines.<locals>.<listcomp>Ô   s(   ø€ Ð>Ð>Ð>¨¸Ð>ˆoˆo˜dÑ#Ô#Ð>Ð>Ð>r$   )r   Ústrr   Úlookup_patternÚcallablerH   r   )rS   rT   rU   r   s    `  r"   Ú
from_lineszPathSpec.from_lines¶   s£   ø€ õ* �¥Ñ%Ô%ð :ÝÔ(¨Ñ9Ô9€?å	�/Ñ	"Ô	"ð LÝ	ÐJ oÐJÐJÐJÑ	KÔ	KÐKå	�eÑ	Ô	ð ;Ý	Ð9˜EÐ9Ð9Ð9Ñ	:Ô	:Ð:à>Ð>Ð>Ð>°Ð>Ñ>Ô>€(Ø	ˆˆX‰ŒÐr$   ©ÚnegateÚentriesr_   c             #   óò   K  — t          |¦  «        st          d|›d�¦  «        ‚t          | j        ¦  «        }|D ];}t	          |j        |¦  «        }|                      ||¦  «        \  }}|r| }|r|V — Œ<dS )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×   s¥   è è € õ2 
�gÑ	Ô	ð ?Ý	Ð=˜gÐ=Ð=Ð=Ñ	>Ô	>Ð>å'¨¬Ñ6Ô6€,Øð ð €eÝ˜eœj¨*Ñ5Ô5€9Ø×%Ò% l°IÑ>Ô>�?€7ˆFàð Øˆk€Gàð Ø
€K€K€Køðð r$   c                 ó–   — t          ||¦  «        }|                      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   rd   s         r"   Ú
match_filezPathSpec.match_file  sB   € õ" ˜T :Ñ.Ô.€)Ø×$Ò$¥Y¨t¬}Ñ%=Ô%=¸yÑIÔI�/€'ˆ6Ý	ˆg‰ŒÐr$   c             #   óè   K  — t          |¦  «        st          d|›d�¦  «        ‚t          | j        ¦  «        }|D ]6}t	          ||¦  «        }|                      ||¦  «        \  }}|r| }|r|V — Œ7d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:`~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   rd   s	            r"   Úmatch_fileszPathSpec.match_files  s£   è è € õ4 
�eÑ	Ô	ð ;Ý	Ð9˜EÐ9Ð9Ð9Ñ	:Ô	:Ð:å'¨¬Ñ6Ô6€,Øð ð €iÝ˜i¨Ñ4Ô4€9Ø×%Ò% l°IÑ>Ô>�?€7ˆFàð Øˆk€Gàð Ø
€O€O€Oøðð 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`).
		rP   r^   N)r   Úiter_tree_entriesre   )r!   rL   rM   rN   r_   r`   s         r"   Úmatch_tree_entrieszPathSpec.match_tree_entriesB  sQ   è è € õ@ Ô" 4°(ÈÐVÑVÔV€'Ø×Ò °ÐÑ7Ô7Ð7Ð7Ð7Ð7Ð7Ð7Ð7Ð7Ð7r$   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`).
		rP   r^   N)r   rQ   rj   )r!   rL   rM   rN   r_   rD   s         r"   Úmatch_tree_fileszPathSpec.match_tree_filese  sQ   è è € õ@ Ô
˜t¨hÀ\Ð
RÑ
RÔ
R€%Ø×Ò˜e¨FÐÑ3Ô3Ð3Ð3Ð3Ð3Ð3Ð3Ð3Ð3Ð3r$   r(   )NN)+Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r#   Úobjectrg   r1   Úintr4   r   r8   r:   r   r	   r   rZ   r   rC   r   rK   r   r   ÚOSErrorrR   Úclassmethodr
   r   r   r]   r   re   Ústaticmethodr   Úcheck_match_filer>   rh   rj   rm   ro   Ú
match_treer)   r$   r"   r   r   '   sf  € € € € € ðð ð
˜h wÔ/ð °Dð ð ð ð ð 	˜ð 	 Dð 	ð 	ð 	ð 	ð�cð ð ð ð ð�4ð  
ð ¨tð ð ð ð ð	�Dð 	 ð 	°ð 	ð 	ð 	ð 	ð +/ð+ð +àð+ð �z #”Ô'ð+ð �(Ôð	+ð +ð +ð +ð0 +/ð0ð 0à	�(Ô	ð0ð �z #”Ô'ð0ð ˆ{˜8Ô$Ô%ð	0ð 0ð 0ð 0ð> 37Ø!%ð	%ð %àð%ð �X˜w˜i¨˜oÔ.Ô/ð%ð ˜”ð	%ð
 ˆ{˜3ÔÔ ð%ð %ð %ð %ðB ðØˆD„zðà˜˜h¨ x°Ð'8Ô9Ð9Ô:ðð 
�&Ô	ðð ð	ð ð ñ „+ððF +/ð%ð
  ð%ð %ð %à�IÔð%ð �z #”Ô'ð%ð
 �4Œ.ð%ð ˆyÔð%ð %ð %ð %ðN ˆ|˜DÔ1Ñ2Ô2€ðð +/ðð àðð �z #”Ô'ðð ð	ð ð ð ð0 +/ð&ð
  ð&ð &ð &à	�'Ô	ð&ð �z #”Ô'ð&ð
 �4Œ.ð&ð ˆwÔð&ð &ð &ð &ðV 37Ø!%ð	!8ð  ð!8ð !8ð !8àð!8ð �X˜w˜i¨˜oÔ.Ô/ð!8ð ˜”ð	!8ð �4Œ.ð!8ð ˆyÔð!8ð !8ð !8ð !8ðL 37Ø!%ð	!4ð  ð!4ð !4ð !4àð!4ð �X˜w˜i¨˜oÔ.Ô/ð!4ð ˜”ð	!4ð �4Œ.ð!4ð ˆs„mð!4ð !4ð !4ð !4ðJ €€€r$   N)rs   Úcollections.abcr   r   Ú	itertoolsr   Útypingr   r   r   r   r	   r
   r   r   Ú r   Úpatternr   r   r   r   r   r   r   r   r   rt   r   r)   r$   r"   ú<module>r€      sž  ððð ðð ð ð ð ð ðð ð ð ð ð ð	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð Ð Ð Ð Ð Ð ð
ð 
ð 
ð 
ð 
ð 
ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð €wˆv˜ZÐ(Ñ(Ô(€ððcð cð cð cð cˆvñ cô cð cð cð cr$   