
    0yi                        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!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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     T/var/www/html/content_weaver/venv/lib/python3.12/site-packages/pathspec/gitignore.pyr   zGitIgnoreSpec.__eq__7   s1     }%
'.
%"

    Nbackend_test_backend_factoryc                    y N )clspattern_factorylinesr'   r(   s        r$   
from_lineszGitIgnoreSpec.from_linesE        r%   c                    y r*   r+   )r,   r.   r-   r'   r(   s        r$   r/   zGitIgnoreSpec.from_linesQ   r0   r%   c               T   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.
			gitignorezpattern_factory=z cannot be z) because it will give unexpected results.r&   )r   strbytescallabler   r   r   
issubclassr   	TypeErrorr   r/   r
   r   )r,   r.   r-   r'   r(   r!   r#   s         r$   r/   zGitIgnoreSpec.from_lines]   s    < e%%l?>[!?E?)?+% *?%#O4?!67	+&;%< =$ %
 
 
	OUG[p		q$	dD	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, Callable[[AnyStr], Pattern], None]r.   Iterable[AnyStr]r'   "Union[BackendNamesHint, str, None]r(   1Optional[Callable[[Sequence[Pattern]], _Backend]]r>   r   r*   )r,   r@   r.   rB   r-   rA   r'   rC   r(   rD   r>   r   )r:   r   r;   zSequence[Pattern]r>   r   )__name__
__module____qualname____doc__r   r   classmethodr/   r   staticmethodr<   __classcell__)r#   s   @r$   r   r   0   su     15MQ@ 

 . K     DH
 15MQ	 A
 . K     DH1
 15MQ11	1 A1
 .1 K1 1  1f 000 0  0r%   N)"rH   
__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   r+   r%   r$   <module>rW      sg    # 
 v_-u0H u0r%   