
    \je                        d Z ddlmZ ddlZddlmZmZ ddlmZ ddl	m
Z
mZmZmZ ddlmZmZmZ  ed	d
      Z	  G d de      Z G d d
e      Z e        G d de             Zy)z8
This module provides the base definition for patterns.
    )annotationsN)IterableIterator)	dataclass)AnyOptionalTypeVarUnion   )AnyStr
deprecatedoverrideRegexPatternSelfRegexPattern)boundc                  B    e Zd ZdZdZddZ ed      d	d       Zd
dZy)PatternzG
	The :class:`Pattern` class is the abstract definition of a pattern.
	includec                    || _         y)z
		Initializes the :class:`Pattern` instance.

		*include* (:class:`bool` or :data:`None`) is whether the matched files
		should be included (:data:`True`), excluded (:data:`False`), or is a
		null-operation (:data:`None`).
		Nr   )selfr   s     :/root/env/lib/python3.12/site-packages/pathspec/pattern.py__init__zPattern.__init__'   s     $,    zXPattern.match() is deprecated. Use Pattern.match_file() with a loop for similar results.c              #  F   K   |D ]  }| j                  |      |  yw)a  
		.. version-deprecated:: 0.10.0
			This method is no longer used. Use the :meth:`self.match_file <.Pattern.match_file>`
			method with a loop for similar results.

		Matches this pattern against the specified files.

		*files* (:class:`~collections.abc.Iterable` of :class:`str`) contains each
		file relative to the root directory.

		Returns an :class:`~collections.abc.Iterable` yielding each matched file
		path (:class:`str`).
		N)
match_file)r   filesfiles      r   matchzPattern.match7   s+     $  d
ood'
Js   !!c                L    t        dj                  | j                              )z
		Matches this pattern against the specified file.

		*file* (:class:`str`) is the normalized file path to match against.

		Returns the match result if *file* matched; otherwise, :data:`None`.
		z?{cls.__module__}.{cls.__qualname__} must override match_file().)cls)NotImplementedErrorformat	__class__)r   r   s     r   r   zPattern.match_fileM   s$     	D
Ft~~F	   r   N)r   Optional[bool]returnNone)r   zIterable[str]r&   zIterator[str])r   strr&   zOptional[Any])	__name__
__module____qualname____doc__	__slots__r   r   r   r    r   r   r   r      s6    
  	$
 r   r   c                       e Zd ZdZdZ	 d
	 	 	 	 	 d fdZddZddZddZddZ	e
dd       Ze	 	 	 	 dd	       Z xZS )r   za
	The :class:`RegexPattern` class is an implementation of a pattern using
	regular expressions.
	)patternregexc                v   d}t        |t        t        f      rL|J d|d|d       | j                  |      \  }}|X|J d|d|d       t	        j
                  |      }n2|t        |d      r|}n!||J d|d|d	       t        d
|d      t        t        | +  |       || _        	 || _        y)a(  
		Initializes the :class:`RegexPattern` instance.

		*pattern* (:class:`str`, :class:`bytes`, :class:`re.Pattern`, or
		:data:`None`) is the pattern to compile into a regular expression.

		*include* (:class:`bool` or :data:`None`) must be :data:`None` unless
		*pattern* is a precompiled regular expression (:class:`re.Pattern`) in which
		case it is whether matched files should be included (:data:`True`), excluded
		(:data:`False`), or is a null operation (:data:`None`).

			.. note:: Subclasses do not need to support the *include* parameter.
		Nzinclude=z must be null when pattern=z is a string.z
raw_regex=z must be non-null when include=z is not None.r   z	 is null.zpattern=z& is not a string, re.Pattern, or None.)
isinstancer(   bytespattern_to_regexrecompilehasattr	TypeErrorsuperr   r   r0   r1   )r   r0   r   r1   	raw_regexr$   s        r   r   zRegexPattern.__init__f   s   $ !%%#u&
/ wl.g\?/ --g69g   	~5WLF  JJy!Eww8 5 / wl.g\;/
 
hg\!GH	IId$W-6=$,
 &+$*r   c                h    | j                   j                   d| j                  d| j                  dS )z;
		Returns a debug representation of this regex pattern.
		z	(pattern=z
, include=))r$   r)   r0   r   r   s    r   __repr__zRegexPattern.__repr__   s3     NN##$Idll-=ZGWWX	YYr   c                4    t        | j                  xs d      S )z
		Returns a string representation of this regex pattern. Equivalent to uncompiled pattern.

		The string representation is the uncompiled pattern if it is not
		:data:`None`; otherwise, an empty string.
		 )r(   r0   r>   s    r   __str__zRegexPattern.__str__   s     
T\\R	  r   c                t    | j                  | j                  | j                        }| j                  |_        |S )zZ
		Performa a shallow copy of the pattern.

		Returns the copy (:class:`RegexPattern`).
		)r$   r1   r   r0   r   others     r   __copy__zRegexPattern.__copy__   s,     ..T\\
2%,,%-	,r   c                    t        |t              r4| j                  |j                  k(  xr | j                  |j                  k(  S t        S )z
		Tests the equality of this regex pattern with *other* (:class:`RegexPattern`)
		by comparing their :attr:`~Pattern.include` and :attr:`~RegexPattern.regex`
		attributes.
		)r3   r   r   r1   NotImplementedrD   s     r   __eq__zRegexPattern.__eq__   s9     |$
,,%--
'
EDJJ%++,EE
r   c                \    | j                   x}|j                  |      x}t        |      S y)a  
		Matches this pattern against the specified file.

		*file* (:class:`str` or :class:`bytes`) is the file path relative to the
		root directory (e.g., "relative/path/to/file").

		Returns the match result (:class:`.RegexMatchResult`) if *file* matched;
		otherwise, :data:`None`.
		N)r1   searchRegexMatchResult)r   r   r1   r   s       r   r   zRegexPattern.match_file   s5     ZZE$d##0
5
!!	r   c                
    |dfS )aF  
		Convert the pattern into an uncompiled regular expression.

		*pattern* (:class:`str` or :class:`bytes`) is the pattern to convert into a
		regular expression.

		Returns a :class:`tuple` containing:

			-	*pattern* (:class:`str`, :class:`bytes` or :data:`None`) is the
				uncompiled regular expression .

			-	*include* (:class:`bool` or :data:`None`) is whether matched files
				should be included (:data:`True`), excluded (:data:`False`), or is a
				null-operation (:data:`None`).

			.. note:: The default implementation simply returns *pattern* and
			   :data:`True`.
		Tr.   )r!   r0   s     r   r5   zRegexPattern.pattern_to_regex   s    . 4r   )N)r0   zUnion[AnyStr, re.Pattern, None]r   r%   r&   r'   )r&   r(   )r   r   r&   r   )rE   objectr&   bool)r   r   r&   zOptional[RegexMatchResult])r0   r   r&   z'tuple[Optional[AnyStr], Optional[bool]])r)   r*   r+   r,   r-   r   r?   rB   rF   rI   r   r   classmethodr5   __classcell__)r$   s   @r   r   r   Z   s     !;*; ; 	;zZ!	  $  . r   c                       e Zd ZU dZdZded<   y)rL   zq
	The :class:`RegexMatchResult` data class is used to return information about
	the matched regular expression.
	)r   zre.Matchr   N)r)   r*   r+   r,   r-   __annotations__r.   r   r   rL   rL      s     	r   rL   )r,   
__future__r   r6   collections.abcr   r   dataclassesr   typingr   r   r	   r
   _typingr   r   r   r   rN   r   r   rL   r.   r   r   <module>rY      s~    # 	  
 -^D 
: f : zW7 Wt v  r   