
    0yi'                        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     R/var/www/html/content_weaver/venv/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                  r     e Zd ZdZdZ	 d	 	 	 	 	 d	 f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                X   t        |t        t        f      r<|J d|d|d       | j                  |      \  }}|Kt	        j
                  |      }n5|t        |d      r|}n$||J d|d|d       d}n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.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   r$   s       r   r   zRegexPattern.__init__f   s    & #u&
/ wk4WK}M/ ))'2>5' JJuEww8 5 / wk4WKyI/ 5 
Xg[(NO	PPd$W-29$,
 &+$*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   NotImplementedr<   s     r   __eq__zRegexPattern.__eq__   s9     |$
,,%--
'
EDJJ%++,EE
r   c                l    | j                   (| j                  j                  |      }|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)r   r1   searchRegexMatchResult)r   r   r   s      r   r   zRegexPattern.match_file   s6     
\\::T"5E""	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    . 
$r   )N)r0   zUnion[AnyStr, re.Pattern, None]r   r%   r&   r'   )r   r   r&   r   )r=   r   r&   bool)r   r   r&   zOptional[RegexMatchResult])r0   r   r&   z'tuple[Optional[AnyStr], Optional[bool]])r)   r*   r+   r,   r-   r   r>   rA   r   r   classmethodr5   __classcell__)r$   s   @r   r   r   Z   sz     !9*9 9 	9v	  "  . r   c                       e Zd ZU dZdZded<   y)rD   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   rD   rD      s     	r   rD   )r,   
__future__r   r6   collections.abcr   r   dataclassesr   typingr   r   r	   r
   _typingr   r   r   r   objectr   r   rD   r.   r   r   <module>rQ      s~    # 	  
 -^D 
: f : zE7 EP v  r   