
    &`i&                         d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	m
Z
 dZ G d	 d
e
          Z ej        de            G d de          Z ej        de           dS )z
This module implements Git's wildmatch pattern matching which itself is
derived from Rsync's wildmatch. Git uses wildmatch for its ".gitignore"
files.
    )unicode_literalsN   )util)unicode)RegexPatternlatin1c                   X    e Zd ZdZdZed             Zed             Zed             Z	dS )GitWildMatchPatternzX
	The :class:`GitWildMatchPattern` class represents a compiled Git
	wildmatch pattern.
	 c                 @   t          |t                    rt          }nYt          |t                    r"t          }|                    t                    }n"t          d                    |                    |                                }|                    d          rd}d}nQ|dk    rd}d}nE|r>|                    d          rd}|dd         }nd}|                    d	          r
|dd         }|	                    d          }|d
         s|d
= nRt          |          dk    st          |          dk    r+|d         s#|d
         dk    r|                    d
d           n	 |d         st          |          dk    rd|d<   dg}d}t          |          dz
  }t          |          D ]\  }	}
|
dk    rt|	d
k    r|	|k    r|                    d           .|	d
k    r|                    d           d}L|	|k    r|                    d           h|                    d           d}|
dk    r/|r|                    d           |                    d           d}|r|                    d           |                    |                     |
                     |	|k    r|du r|                    d           d}|                    d           d                    |          }nd}d}|#|t          u r|                    t                    }||fS )a  
		Convert the pattern into a regular expression.

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

		Returns the uncompiled regular expression (:class:`unicode`, :class:`bytes`,
		or :data:`None`), and whether matched files should be included
		(:data:`True`), excluded (:data:`False`), or if it is a
		null-operation (:data:`None`).
		z-pattern:{!r} is not a unicode or byte string.#N/!F   T\r   r   z**^z.+z(?:.+/)?z/.*z(?:/.+)?*z[^/]+z(?:/.*)?$ )
isinstancer   bytesdecode_BYTES_ENCODING	TypeErrorformatstrip
startswithsplitleninsert	enumerateappend_translate_segment_globjoinencode)clspatternreturn_typeregexincludepattern_segsoutput
need_slashendisegs              /home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/_private/thirdparty/pathspec/patterns/gitwildmatch.pypattern_to_regexz$GitWildMatchPattern.pattern_to_regex   s    !! T;;'5!! T;^^O,,77	BII'RR	S	SSMMOO' u 577#~~ 577 h 	
 GabbkGGG  abbkG --$$< q/ 	
 	QLQ3|#4#4#9#9,q/#9 A$D!!! 	
r
 s<00144
 L E6:	\		Q	3<(( & &vq#
d{{	Q188 mmD
q&& mmJjj
s(( mmE mmJjj	 mmC]]7ZZ 	 mmC]]3..s33444	SW__ mmJZZ	==776??55
 57
;%//<<((5	    c                    d}d}dt          |           }}||k     r1| |         }|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    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z  }n|t          j        |          z  }||k     1|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   r   Tr   z[^/]*?z[^/][r   ]r   z\^z\\z\[)r    reescapereplace)r(   r:   r*   r0   r/   charjexprs           r2   r$   z+GitWildMatchPattern._translate_segment_glob   s    &
%c'llS!	C
!*461 PF	RYt__EEFF 
WEE 
VOEE 	
A3ww71:$$!VQ 	3ww71:$$!VQ
c''gajC''!VQ c''gajC'' 	3ww !VQT
c
ckd1faa
!*

 emd1fa 
WQqS\!!$///T d]U 
QQ
 e^UU 
RYt__Ek 	
Cn 
,r4   c                 J    dd                     fd| D                       S )z
		Escape special characters in the given string.

		*s* (:class:`unicode` 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:`unicode`, :class:`bytes`)
		z[]!*#?r   c              3   .   K   | ]}|v rd |z   n|V  dS )r   Nr   ).0xmeta_characterss     r2   	<genexpr>z-GitWildMatchPattern.escape.<locals>.<genexpr>'  s5      DDQQ/11qDDDDDDr4   )r%   )srC   s    @r2   r:   zGitWildMatchPattern.escape  s1     /	DDDD!DDD	D	DDr4   N)
__name__
__module____qualname____doc__	__slots__classmethodr3   staticmethodr$   r:   r   r4   r2   r
   r
      s          P P +Pd g g ,gR E E ,E E Er4   r
   gitwildmatchc                   R     e Zd ZdZ fdZed             Ze fd            Z xZ	S )GitIgnorePatternz
	The :class:`GitIgnorePattern` class is deprecated by :class:`GitWildMatchPattern`.
	This class only exists to maintain compatibility with v0.4.
	c                 l    |                                    t          t          |           j        |i |S 
		Warn about deprecation.
		)_deprecatedsuperrO   __init__)selfargskw	__class__s      r2   rU   zGitIgnorePattern.__init__2  s:     	/	&	&	/	<	<	<<r4   c                  >    t          j        dt          d           dS )rR   z_GitIgnorePattern ('gitignore') is deprecated. Use GitWildMatchPattern ('gitwildmatch') instead.   )
stacklevelN)warningswarnDeprecationWarningr   r4   r2   rS   zGitIgnorePattern._deprecated9  s>    
 -q  tF  ST  U  U  U  U  U  Ur4   c                 l    |                                    t          t          |           j        |i |S rQ   )rS   rT   rO   r3   )r'   rW   rX   rY   s      r2   r3   z!GitIgnorePattern.pattern_to_regex@  s8    
 //	6	%	%	6	C	C	CCr4   )
rF   rG   rH   rI   rU   rL   rS   rK   r3   __classcell__)rY   s   @r2   rO   rO   ,  s         
= = = = = U U ,U D D D D +D D D D Dr4   rO   	gitignore)rI   
__future__r   r9   r]   r   r   compatr   r(   r   r   r
   register_patternrO   r   r4   r2   <module>rf      s   
 ( ' ' ' ' ' 				              " " " " " " SE SE SE SE SE, SE SE SEj  n&9 : : :D D D D D* D D D<  k#3 4 4 4 4 4r4   