
    ]O,j                         d Z ddlZddlmZ ddlmZ ddlmZmZ dZ		  G d de          Z
 G d	 d
e          Z G d de          ZdS )zA
This module provides common classes for the gitignore patterns.
    N)Literal)RegexPattern)AnyStrassert_unreachablelatin1c                   f    e Zd ZdZdZededefd            Zedede	d         defd	            Z
d
S )_GitIgnoreBasePatternz
	.. warning:: This class is not part of the public API. It is subject to
		change.

	The :class:`_GitIgnoreBasePattern` class is the base implementation for a
	compiled gitignore pattern.
	 sreturnc                 `   t          | t                    r
t          }| }nJt          | t                    r"t          }|                     t                    }nt          d| d          d                    d |D                       }|t          u r|                    t                    }|S |S )z
		Escape special characters in the given string.

		*s* (:class:`str` or :class:`bytes`) a filename or a string that you want to
		escape, usually before adding it to a ".gitignore".

		Returns the escaped string (:class:`str` or :class:`bytes`).
		zs:z! is not a unicode or byte string. c              3   ,   K   | ]}|d v rd| n|V  dS )z\[]!*#?\Nr
   ).0xs     h/home/thesage/.hermes/hermes-agent/venv/lib/python3.11/site-packages/pathspec/patterns/gitignore/base.py	<genexpr>z/_GitIgnoreBasePattern.escape.<locals>.<genexpr>6   s4      LLAOOQLLLLLL    )
isinstancestrbytesdecode_BYTES_ENCODING	TypeErrorjoinencode)r   return_typestring
out_string	out_bytess        r   escapez_GitIgnoreBasePattern.escape"   s     3 @;66!U @;HH_%%66	>>>>	?	?? wwLLVLLLLL*E  119

r   patternrange_error)literalraisec                 d   d}d}dt          |           }}||k     r| |         }|dz  }|rd}|t          j        |          z  }nN|dk    rd}nD|dk    r|dz  }n7|d	k    r|d
z  }n*|dk    r|}||k     r| |         dk    s| |         dk    r|dz  }||k     r| |         dk    r|dz  }||k     r#| |         dk    r|dz  }||k     r| |         dk    ||k     r]|dz  }d}| |         dk    r|dz  }|dz  }n| |         dk    r
|dz  }|dz  }|| ||                             dd          z  }||z  }|}n[|dk    r|dz  }nO|dk    rt	          d| ||         d| d          t          d|d           n|t          j        |          z  }||k     |rt          d|           |S )a  
		Translates the glob pattern to a regular expression. This is used in the
		constructor to translate a path segment glob pattern to its corresponding
		regular expression.

		*pattern* (:class:`str`) is the glob pattern.

		*range_error* (:class:`int`) is how to handle invalid range notation in the
		pattern:

		-	:data:`"literal"`: Invalid notation will be treated as a literal string.

		-	:data:`"raise"`: Invalid notation will cause a :class:`_RangeError` to be
			raised.

		Returns the regular expression (:class:`str`).
		Fr   r      r   T*z[^/]*?z[^/][!^]z\\r%   z\[r&   zInvalid range notation=z found in pattern=.zrange_error=z is invalid.z9Escape character found with no next character to escape: )lenrer"   replace_RangeErrorr   
ValueError)	r#   r$   r"   regexiendcharjexprs	            r   _translate_segment_globz-_GitIgnoreBasePattern._translate_segment_glob>   s   2 &
%c'llS!	C
!*461 \F	RYt__EEFF 
WEE 
VOEE 	
A 	3wwGAJ#%%s):):!VQ 	3ww71:$$!VQ c''gajC''!VQ c''gajC'' 	3ww !VQT
c
ckd1faa
!*

 ckd1fa 
WQqS\!!$///T d]U 
QQ 	y   unee

 
 1  
  	 	 	
 8K8889999 
RYt__EC 	
CF  	KKK
 
  
,r   N)__name__
__module____qualname____doc__	__slots__staticmethodr   r"   r   r   r;   r
   r   r   r	   r	      s          v &    ,6 CC)*C 
C C C ,C C Cr   r	   c                       e Zd ZdZdS )GitIgnorePatternErrorzU
	The :class:`GitIgnorePatternError` class indicates an invalid gitignore
	pattern.
	Nr<   r=   r>   r?   r
   r   r   rC   rC                r   rC   c                       e Zd ZdZdS )r3   zi
	The :class:`_RangeError` class indicates an invalid range notation was found
	in a gitignore pattern.
	NrD   r
   r   r   r3   r3      rE   r   r3   )r?   r1   typingr   pathspec.patternr   pathspec._typingr   r   r   r	   r4   rC   r3   r
   r   r   <module>rJ      s    
			
 
 
 
 
 
             
l l l l lL l l l^    J       '     r   