
    ni                        d 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 ddlmZmZ ddlmZ ddl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  e	dd          Z 	  G d de          Z!dS )aQ  
This module provides :class:`.GitIgnoreSpec` which replicates *.gitignore*
behavior, and handles edge-cases where Git's behavior differs from what's
documented. Git allows including files from excluded directories which directly
contradicts the documentation. This uses :class:`.GitIgnoreSpecPattern` to fully
replicate Git's handling.
    )annotations)IterableSequence)CallableOptionalTypeVarUnioncastoverload)BackendNamesHint_Backendmake_gitignore_backend)PathSpec)Pattern)GitIgnoreBasicPattern)GitIgnoreSpecPattern)AnyStroverride)_is_iterablelookup_patternSelfGitIgnoreSpec)boundc                       e Zd ZdZd fdZeeddddd                        Zee	 ddddd d                        Zee	 ddddd  fd                        Zee	d!d                        Z
 xZS )"r   z
	The :class:`GitIgnoreSpec` class extends :class:`.PathSpec` to replicate
	*gitignore* behavior. This is uses :class:`.GitIgnoreSpecPattern` to fully
	replicate Git's handling.
	otherobjectreturnboolc                    t          |t                    r!t                                          |          S t          |t                    rdS t
          S )z
		Tests the equality of this gitignore-spec with *other* (:class:`.GitIgnoreSpec`)
		by comparing their :attr:`self.patterns <.PathSpec.patterns>` attributes. A
		non-:class:`GitIgnoreSpec` will not compare equal.
		F)
isinstancer   super__eq__r   NotImplemented)selfr   	__class__s     O/var/www/html/gpu-tools/venv/lib/python3.11/site-packages/pathspec/gitignore.pyr#   zGitIgnoreSpec.__eq__7   sJ     }%% 
''..

%"" 
%
    Nbackend_test_backend_factorycls
type[Self]pattern_factory-Union[str, Callable[[AnyStr], Pattern], None]linesIterable[AnyStr]r*   "Union[BackendNamesHint, str, None]r+   1Optional[Callable[[Sequence[Pattern]], _Backend]]r   c                   d S N )r,   r.   r0   r*   r+   s        r'   
from_lineszGitIgnoreSpec.from_linesE   	     #r(   c                   d S r5   r6   )r,   r0   r.   r*   r+   s        r'   r7   zGitIgnoreSpec.from_linesQ   r8   r(   c                  t          |t          t          f          st          |          rt	          |          r||}}|t
          }n|dk    rt
          }t          |t                    rt          |          }t          |t                    rt          d|dt           d          t                                          ||||          }t          t          |          S )a  
		Compiles the pattern lines.

		*lines* (:class:`~collections.abc.Iterable`) yields each uncompiled pattern
		(:class:`str`). This simply has to yield each line, so it can be a
		:class:`io.TextIOBase` (e.g., from :func:`open` or :class:`io.StringIO`) or
		the result from :meth:`str.splitlines`.

		*pattern_factory* does not need to be set for :class:`GitIgnoreSpec`. If
		set, it should be either ``"gitignore"`` or :class:`.GitIgnoreSpecPattern`.
		There is no guarantee it will work with any other pattern class. Default is
		:data:`None` for :class:`.GitIgnoreSpecPattern`.

		*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.

		Returns the :class:`GitIgnoreSpec` instance.
		N	gitignorezpattern_factory=z cannot be z) because it will give unexpected results.r)   )r!   strbytescallabler   r   r   
issubclassr   	TypeErrorr"   r7   r
   r   )r,   r0   r.   r*   r+   r%   r&   s         r'   r7   zGitIgnoreSpec.from_lines]   s    < e%% 3% 3l?>[>[ 3!?E?)??+%% *?%% 5#O44?!677 	% % %&; % % %
 
 
 
		OUG[p		q	q$	dD		r(   namer   patterns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 backend (:class:`._Backend`).
		r   )rA   rB   s     r'   _make_backendzGitIgnoreSpec._make_backend   s    & 
 h	/	//r(   )r   r   r   r   )r,   r-   r.   r/   r0   r1   r*   r2   r+   r3   r   r   r5   )r,   r-   r0   r1   r.   r/   r*   r2   r+   r3   r   r   )rA   r   rB   rC   r   r   )__name__
__module____qualname____doc__r#   r   classmethodr7   r   staticmethodrE   __classcell__)r&   s   @r'   r   r   0   sH               15MQ     + (  DH
 15MQ     + (  DH1
 15MQ1 1 1 1 1 1 1 + (1f 0 0 0 , (0 0 0 0 0r(   N)"rI   
__future__r   collections.abcr   r   typingr   r   r   r	   r
   r   pathspec.backendr   r   pathspec._backends.aggr   pathspec.pathspecr   pathspec.patternr   !pathspec.patterns.gitignore.basicr    pathspec.patterns.gitignore.specr   pathspec._typingr   r   pathspec.utilr   r   r   r   r6   r(   r'   <module>rX      s    # " " " " "                                       
 
 
 
 
 
                         wv_---u0 u0 u0 u0 u0H u0 u0 u0 u0 u0r(   