Ë
    hKêjÇ  ã                  óº   — d Z ddlmZ ddlmZ ddlmZmZ 	 ddlZddl
mZ ddlmZ ddlmZ d	d
lmZ ddlmZ ddlmZmZmZ  G d„ de«      Zy# e	$ r dZY Œ=w xY w)zÙ
This module provides the :module:`re2` backend for :class:`~pathspec.pathspec.PathSpec`.

WARNING: The *pathspec._backends.re2* package is not part of the public API. Its
contents and structure are likely to change.
é    )Úannotations)ÚSequence)ÚCallableÚOptionalN)Ú_Backend)ÚRegexPattern)Úoverrideé   )Úenumerate_patternsé   )Ú	re2_error)ÚRE2_OPTIONSÚRe2RegexDatÚRe2RegexDebugc                  óx   — e Zd ZdZdddœ	 	 	 	 	 	 	 dd„Ze	 	 	 	 	 	 	 	 	 	 d	d„«       Zed
d„«       Zedd„«       Z	y)ÚRe2PsBackendz‰
	The :class:`Re2PsBackend` class is the :module:`re2` implementation used by
	:class:`~pathspec.pathspec.PathSpec` for matching files.
	N)Ú_debug_regexÚ
_test_sortc               óB  — t         �t         ‚|r%t        |d   t        «      st        d|d   ›d�«      ‚t	        t        |dd¬«      «      }| j                  «       }t        |«      | _        	 || _	        	 | j                  | j                  |||¬«      | _        	 || _        y)	z’
		Initialize the :class:`Re2PsBackend` instance.

		*patterns* (:class:`Sequence` of :class:`.RegexPattern`) contains the
		compiled patterns.
		Nr   zpatterns[0]=z must be a RegexPattern.TF)ÚfilterÚreverse)ÚdebugÚpatternsÚ	regex_setÚsort_indices)r   Ú
isinstancer   Ú	TypeErrorÚdictr   Ú	_make_setÚboolr   Ú	_patternsÚ	_init_setÚ_regex_dataÚ_set)Úselfr   r   r   Úuse_patternsr   s         úd/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/pathspec/_backends/re2/pathspec.pyÚ__init__zRe2PsBackend.__init__,   s½   € ô ÐÜ	€?á”j ¨!¡¬lÔ;Ü	�l�h˜q‘kÐ%Ð%=Ð>Ó	?Ð?äÔ(Ø�D %ôó €,ð �n‰nÓ€)ä˜<Ó(€$Ôðð
 -9€$„.ðð
 )-¯©Ø	×	Ñ	ØØØð	 )7ó )€$Ôðð
 !€$„)ðó    c           	     óè  — t        |j                  «       «      }|� ||«       g }|D ]·  }||   }|j                  €Œ|j                  €J |«       ‚t	        |t
        «      sJ |«       ‚|j                  j                  }| r)|j                  t        |j                  |d|¬«      «       n'|j                  t        |j                  |d¬«      «       |j                  |«       Œ¹ |j                  «        |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`).
		F)ÚincludeÚindexÚis_dir_patternÚregex)r+   r,   r-   )ÚlistÚkeysr+   r.   r   r   ÚpatternÚappendr   r   ÚAddÚCompile)	r   r   r   r   ÚindicesÚ
regex_dataÚpattern_indexr1   r.   s	            r'   r"   zRe2PsBackend._init_set`   sö   € ô4 �—‘“Ó!€'ØÐÙ�Ôð #%€*Øò €mØ�mÑ$€7Ø‡o�oÐØà
�-‰-Ð
#Ð, WÓ,Ð
#Ü
�WœlÔ
+Ð4¨WÓ4Ð
+Ø�=‰=× Ñ €5áØ×Ñ”mØ�_‰_ØØØô	õ ð ×Ñ”kØ�_‰_ØØôô ð ‡=�=�Õð/ð4 ×ÑÔØ	Ðr)   c                 óv   — t         €J t         t        f«       ‚t         j                  j                  t        «      S )zF
		Create the re2 regex set.

		Returns the set (:class:`re2.Set`).
		)Úre2r   ÚSetÚ	SearchSetr   © r)   r'   r   zRe2PsBackend._make_set�   s-   € ô 
ˆÐ*œ3¤	Ð*Ó*ˆÜ	�‰×	Ñ	œ;Ó	'Ð'r)   c                óº   ‡— | j                   j                  |«      }|sy| j                  Št        ˆfd„|D «       «      }| j                  |   }|j
                  |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`).
		)NNc              3  ó<   •K  — | ]  }‰|   j                   –— Œ y ­w)N)r,   )Ú.0Ú_Re2PsBackend__idr6   s     €r'   ú	<genexpr>z*Re2PsBackend.match_file.<locals>.<genexpr>»   s   øè ø€ ÒC°�j Ñ&×,Õ,ÑCùs   ƒ)r$   ÚMatchr#   Úmaxr!   r+   )r%   ÚfileÚ	match_idsr7   r1   r6   s        @r'   Ú
match_filezRe2PsBackend.match_file§   sU   ø€ ð $(§9¡9§?¡?°4Ó#8€)Ù	Ø
à×Ñ€*ÜÓC¸ÔCÓC€-Ø�N‰N˜=Ñ)€'Ø
�/‰/˜=Ð	)Ð)r)   )r   zSequence[RegexPattern]r   zOptional[bool]r   z Optional[Callable[[list], None]]ÚreturnÚNone)
r   r    r   zdict[int, RegexPattern]r   úre2.Setr   z%Optional[Callable[[list[int]], None]]rG   zlist[Re2RegexDat])rG   rI   )rD   ÚstrrG   z$tuple[Optional[bool], Optional[int]])
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r(   Ústaticmethodr"   r   r	   rF   r<   r)   r'   r   r   &   s¦   „ ñð "&Ø15ñ2à"ð2ð ð	2ð
 /ð2ð ó2ðh ð:Ø	ð:à#ð:ð ð:ð 6ð	:ð
 ò:ó ð:ðx ò(ó ð(ð ò*ó ñ*r)   r   )rN   Ú
__future__r   Úcollections.abcr   Útypingr   r   r9   ÚModuleNotFoundErrorÚpathspec.backendr   Úpathspec.patternr   Úpathspec._typingr	   Ú_utilsr   Úbaser   Ú_baser   r   r   r   r<   r)   r'   ú<module>rZ      sh   ðñõ #õ÷ðÛõõõõõ÷ñ ôW*�8õ W*øð+ ò Ø‚ðús   ˜A ÁAÁA