
    \jB                        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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e         Z"y)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_TestBackendFactoryHint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.
	c                p    t        |t              rt        |   |      S t        |t              ry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)selfother	__class__s     </root/env/lib/python3.12/site-packages/pathspec/gitignore.pyr    zGitIgnoreSpec.__eq__8   s1     }%
'.
%"

    Nbackend_test_backend_factoryc                    y N )clspattern_factorylinesr(   r)   s        r%   
from_lineszGitIgnoreSpec.from_linesF        r&   c                    y r+   r,   )r-   r/   r.   r(   r)   s        r%   r0   zGitIgnoreSpec.from_linesR   r1   r&   c          	     f   t        |t        t        f      st        |      rt	        |      r||}}|t
        }n*|dk(  rt
        }nt        |t              rt        |      }n|}t        |t              r)t        |t              rt        d|d| dt         d      t        | 1  ||||      }|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.
			gitignorezpattern_factory=z (resolved to z) cannot be z) because it will give unexpected results.r'   )r   strbytescallabler   r   r   type
issubclassr   	TypeErrorr   r0   )r-   r/   r.   r(   r)   use_factoryr"   r$   s          r%   r0   zGitIgnoreSpec.from_lines^   s    < e%%l?>[!?E? %;+% &;/3'0; ; k4 +45	)} E&' (
  
	KWl		m$	+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   )namepatternss     r%   _make_backendzGitIgnoreSpec._make_backend   s    & 
 h	//r&   )r#   objectreturnbool)r-   
type[Self]r.   <Union[str, type[Pattern], Callable[[AnyStr], Pattern], None]r/   Iterable[AnyStr]r(   "Union[BackendNamesHint, str, None]r)   r   rA   r   r+   )r-   rC   r/   rE   r.   rD   r(   rF   r)   r   rA   r   )r=   r   r>   zSequence[Pattern]rA   r   )__name__
__module____qualname____doc__r    r   classmethodr0   r   staticmethodr?   __classcell__)r$   s   @r%   r   r   1   sr     1537O 

 . 1     SW
 1537	 P
 . 1     SW7
 153777	7 P7
 .7 17 7  7r 000 0  0r&   N)#rJ   
__future__r   collections.abcr   r   typingr   r   r   r	   r
   r   pathspec.backendr   r   r   pathspec._backends.aggr   pathspec.pathspecr   pathspec.patternr   !pathspec.patterns.gitignore.basicr    pathspec.patterns.gitignore.specr   pathspec._typingr   r   pathspec.utilr   r   r   r   r,   r&   r%   <module>rY      sr    #  
 v_-{0H12 {0r&   