
    ni                        d Z ddlmZ ddlmZmZmZ 	 ddlZn# e$ r dZY nw xY wddl	m
Z
 ddlmZmZmZmZ ddlmZ dd	lmZmZ dd
lmZ  G d de          ZdS )z
This module provides the :module:`re2` backend for :class:`~pathspec.gitignore.GitIgnoreSpec`.

WARNING: The *pathspec._backends.re2* package is not part of the public API. Its
contents and structure are likely to change.
    )annotations)CallableOptionalUnionN)RegexPattern)GitIgnoreSpecPattern_BYTES_ENCODING_DIR_MARK_CG_DIR_MARK_OPT)override   )Re2RegexDatRe2RegexDebug)Re2PsBackendc                  R    e Zd ZdZeedd                        Zedd            ZdS )Re2GiBackendz
	The :class:`Re2GiBackend` class is the :module:`re2` implementation used by
	:class:`~pathspec.gitignore.GitIgnoreSpec` for matching files.
	debugboolpatternsdict[int, RegexPattern]	regex_setre2.Setsort_indices%Optional[Callable[[list[int]], None]]returnlist[Re2RegexDat]c           
     L   t          |                                          }| ||           g }|D ]}||         }|j        t          |t                    s
J |            |j        j        }g }	t          |t                    rt          |t                    r|}
n9t          |t                    s
J |            |
                    t                    }
t          |
v r|
                    t                    rR|
dt          t                              }|	                    | ddf           |	                    | ddf           n2|
                    t          d          }|	                    |df           |	s|	                    |df           |	D ]r\  }}| r,|                    t%          |j        |||                     n*|                    t'          |j        ||                     |                    |           s|                                 |S )aV  
		Create the re2 regex set.

		*debug* (:class:`bool`) is whether to include additional debugging
		information for the regular expressions.

		*patterns* (:class:`dict`) maps pattern index (:class:`int`) to pattern
		(:class:`.RegexPattern`).

		*regex_set* (:class:`re2.Set`) is the regex set.

		*sort_indices* (:class:`callable` or :data:`None`) is a function used to
		sort the patterns by index. This is used during testing to ensure the order
		of patterns is not accidentally relied on.

		Returns a :class:`list` indexed by regex id (:class:`int`) to its data
		(:class:`Re2RegexDat`).
		N/T$F)includeindexis_dir_patternregex)r    r!   r"   )listkeysr    
isinstancer   r#   patternr   strbytesdecoder	   r
   endswithr   lenappendreplacer   r   AddCompile)r   r   r   r   indices
regex_datapattern_indexr'   r#   use_regexes	regex_str
base_regexr"   s                ]/var/www/html/gpu-tools/venv/lib/python3.11/site-packages/pathspec/_backends/re2/gitignore.py	_init_setzRe2GiBackend._init_set*   s}   6 !!'< #%* 4 4mm$7o
Wl
+
+44W444= 579;.// -
 % /YYue$$++e+++o..Yy  =)) 	- 1s=11112jZ***D1222Z***E23333 $$\377j*d+,,,
 'u~&&& +  un }o#	       {o#      MM%$ 	    filer(   $tuple[Optional[bool], Optional[int]]c                   | j                             |          }|sdS d}d}d}| j        }|D ]H}||         }|j        }	|	rd}
nd}
|j        }|j        }|r|	r||k    s|
|k    r||k    s|
|k    r|}|}|
}I|dk    sJ |||f            ||fS )a  
		Check the file against the patterns.

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

		Returns a :class:`tuple` containing whether to include *file* (:class:`bool`
		or :data:`None`), and the index of the last matched pattern (:class:`int` or
		:data:`None`).
		)NNNr      )_setMatch_regex_datar"   r    r!   )selfr:   	match_idsout_include	out_indexout_priorityr2   regex_id	regex_datr"   priorityr    r!   s                r7   
match_filezRe2GiBackend.match_file   s     $(9??4#8#8)	 
, $+),*  h(#9,> HH H 7?5$)I$5$5L  UY%6%6,KIL	b9k<@
y	!!r9   N)
r   r   r   r   r   r   r   r   r   r   )r:   r(   r   r;   )__name__
__module____qualname____doc__r   staticmethodr8   rJ    r9   r7   r   r   $   sm         
 W W W , (Wr -" -" -" (-" -" -"r9   r   )rN   
__future__r   typingr   r   r   re2ModuleNotFoundErrorpathspec.patternr    pathspec.patterns.gitignore.specr   r	   r
   r   pathspec._typingr   _baser   r   pathspecr   r   rP   r9   r7   <module>rZ      s    # " " " " "         
                   
                 O" O" O" O" O"< O" O" O" O" O"s    ##