
    0yiP                     Z    d Z ddlZddlmZ ddlmZ dZ	  G d de      Z G d d	e      Z	y)
zA
This module provides common classes for the gitignore patterns.
    N)RegexPattern)AnyStrlatin1c                   H    e Zd ZdZdZededefd       Zededefd       Z	y)	_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        }| }n;t        | t              rt        }| j                  t              }nt        d| d      dj                  d |D              }|t        u r|j                  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   2   K   | ]  }|d v rd| n|  yw)z[]!*#?\Nr   ).0xs     b/var/www/html/content_weaver/venv/lib/python3.12/site-packages/pathspec/patterns/gitignore/base.py	<genexpr>z/_GitIgnoreBasePattern.escape.<locals>.<genexpr>2   s!     JaAM"QCq8Js   )
isinstancestrbytesdecode_BYTES_ENCODING	TypeErrorjoinencode)r	   return_typestring
out_strings       r   escapez_GitIgnoreBasePattern.escape   s     3;6!U;HH_%6	Ru=>	?? wwJ6JJ*E


O
,,
    patternc                 p   d}d}dt        |       }}||k  r| |   }|dz  }|rd}|t        j                  |      z  }n|dk(  rd}n|dk(  r|dz  }n|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k7  r|dz  }||k  r	| |   dk7  r||k  rL|dz  }d}| |   dk(  r|dz  }|dz  }n| |   dk(  r
|dz  }|dz  }|| || j                  dd      z  }||z  }|}n|dz  }n|t        j                  |      z  }||k  r|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.

		Returns the regular expression (:class:`str`).
		Fr   r      r   T*z[^/]*?z[^/][!^]z\\z\[z9Escape character found with no next character to escape: )lenrer   replace
ValueError)r    r   regexiendcharjexprs           r   _translate_segment_globz-_GitIgnoreBasePattern._translate_segment_glob9   s    &
%c'lS!	C
!*461F	RYYt_EF 
WE 
VOE 	
A 	3wGAJ#%s):!VQ 	3w71:$!VQ c'gajC'!VQ c'gajC' 	3w !VQT
c
ckd1fa
!*
 ckd1fa 
WQq\!!$//T d]U 
Q
 e^U 
RYYt_Eo 	
Cr 	?{K
  
,r   N)
__name__
__module____qualname____doc__	__slots__staticmethodr   r   r   r3   r   r   r   r   r      sT     v &  4 nc nc n nr   r   c                       e Zd ZdZy)GitIgnorePatternErrorzU
	The :class:`GitIgnorePatternError` class indicates an invalid gitignore
	pattern.
	N)r4   r5   r6   r7   r   r   r   r;   r;      s     r   r;   )
r7   r*   pathspec.patternr   pathspec._typingr   r   r   r,   r;   r   r   r   <module>r>      s@    
	 
VL VrJ r   