Ë
    hKêj“  ã                  ó¾   — d Z ddlmZ ddlmZ ddlmZ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:`hyperscan` backend for :class:`~pathspec.pathspec.PathSpec`.

WARNING: The *pathspec._backends.hyperscan* package is not part of the public
API. Its contents and structure are likely to change.
é    )Úannotations)ÚSequence)ÚAnyÚCallableÚOptionalN)Ú_Backend)ÚRegexPattern)Úoverrideé   )Úenumerate_patternsé   )Úhyperscan_error)ÚHS_FLAGSÚHyperscanExprDatÚHyperscanExprDebugc                  ó˜   — e Zd ZdZdddœ	 	 	 	 	 	 	 d	d„Ze	 	 	 	 	 	 	 	 	 	 d
d„«       Zedd„«       Zedd„«       Z		 	 	 	 	 	 	 	 	 	 	 	 dd„Z
y)ÚHyperscanPsBackendzÑ
	The :class:`HyperscanPsBackend` class is the :module:`hyperscan`
	implementation used by :class:`~pathspec.pathspec.PathSpec` for matching
	files. The Hyperscan database uses block mode for matching files.
	N)Ú_debug_exprsÚ
_test_sortc               ó‚  — t         €t        €J t         t        f«       ‚t        ‚|r%t        |d   t        «      st	        d|d   ›d�«      ‚t        |dd¬«      }t        |«      }|r&| j                  «       }| j                  ||||¬«      }nd}g }|| _	        	 || _
        	 || _        	 d	| _        	 t        |«      | _        y)
z˜
		Initialize the :class:`HyperscanPsBackend` instance.

		*patterns* (:class:`Sequence` of :class:`.RegexPattern`) contains the
		compiled patterns.
		Nr   zpatterns[0]=z must be a RegexPattern.TF)ÚfilterÚreverse)ÚdbÚdebugÚpatternsÚsort_ids©Néÿÿÿÿ)Ú	hyperscanr   Ú
isinstancer	   Ú	TypeErrorr   ÚboolÚ_make_dbÚ_init_dbÚ_dbr   Ú
_expr_dataÚ_outÚdictÚ	_patterns)Úselfr   r   r   Úuse_patternsÚdebug_exprsr   Ú	expr_datas           új/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/pathspec/_backends/hyperscan/pathspec.pyÚ__init__zHyperscanPsBackend.__init__.   sð   € ô ÐÜ
Ð
%ÐC¬	´?Ð'CÓCÐ
%Ü	Ðá”j ¨!¡¬lÔ;Ü	�l�h˜q‘kÐ%Ð%=Ð>Ó	?Ð?ä#Ø�D %ô€,ô �\Ó"€+ÙØ�‰‹€2Ø�}‰}Ø	Ø
ØØð	 ó �9ð 	€2Ø€9à+-€$„(ðð "€$Ôðð
 -6€$„/ðð
 +5€$„)ðô -1°Ó,>€$„.ðó    c           	     óÞ  — |sJ |«       ‚g }g }|D ]ú  \  }}|j                   €	J ||f«       ‚|j                  €	J ||f«       ‚t        |t        «      sJ |«       ‚|j                  j                  }t        |t
        «      r|}	n(t        |t        «      sJ |«       ‚|j                  d«      }	|r)|j                  t        |j                   |d|¬«      «       n'|j                  t        |j                   |d¬«      «       |j                  |	«       Œü t        t        t        |«      «      «      }
|� ||
«       |
D �cg c]  }||   ‘Œ	 }}| j                  ||
t        |«      t        ¬«       |S c c}w )a‹  
		Initialize the Hyperscan database from the given patterns.

		*db* (:class:`hyperscan.Hyperscan`) is the Hyperscan database.

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

		*patterns* (:class:`~collections.abc.Sequence` of :class:`.RegexPattern`)
		contains the patterns.

		*sort_ids* (:class:`callable` or :data:`None`) is a function used to sort
		the compiled expression ids. This is used during testing to ensure the order
		of expressions is not accidentally relied on.

		Returns a :class:`list` indexed by expression id (:class:`int`) to its data
		(:class:`HyperscanExprDat`).
		Úutf8F)ÚincludeÚindexÚis_dir_patternÚregex)r3   r4   r5   )ÚexpressionsÚidsÚelementsÚflags)r3   r6   r    r	   ÚpatternÚbytesÚstrÚencodeÚappendr   r   ÚlistÚrangeÚlenÚcompiler   )r   r   r   r   r-   ÚexprsÚpattern_indexr;   r6   Úregex_bytesr8   Ú_HyperscanPsBackend__ids               r.   r$   zHyperscanPsBackend._init_dbu   s‚  € ñ6 
Ð�8Óˆð ')€)Ø€%Ø (ò Ñ€m�WØ
�/‰/Ð
%Ð?¨°wÐ'?Ó?Ð
%Ø
�-‰-Ð
#Ð= m°WÐ%=Ó=Ð
#ô �WœlÔ
+Ð4¨WÓ4Ð
+Ø�=‰=× Ñ €5ä�œÔØ�Kä�eœSÔ!Ð( 5Ó(Ð!Ø—,‘,˜vÓ&€KáØ×ÑÔ'Ø�_‰_ØØØô	õ ð ×ÑÔ%Ø�_‰_ØØôô ð 	‡<�<�Õð9ô> 	ŒU”3�u“:ÓÓ€#ØÐÙˆC„=Ø$'Ö(˜DˆE�$‹KÐ(€5Ð(ð ‡*�*ØØ
Ü�‹JÜ	ð	 ô ð 
Ðùò )s   Ä8E*c                óº   — | j                   }|€yd| _        |j                  |j                  d«      | j                  ¬«       | j                  \  }}|dk(  rd}||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`).
		N)NNr   r2   )Úmatch_event_handlerr   )r%   r'   Úscanr>   Ú_HyperscanPsBackend__on_match)r*   Úfiler   Úout_includeÚ	out_indexs        r.   Ú
match_filezHyperscanPsBackend.match_fileÃ   sb   € ð ‡x�x€"Ø€Zð à€$„)Ø‡'�'ˆ$�+‰+�fÓ
°4·?±?€'ÔCð  Ÿ9™9Ñ€+ˆyØ�"‚_Ø€9à
�yÐ	!Ð!r0   c                 óx   — t         €J t         t        f«       ‚t        j                  t         j                  ¬«      S )z[
		Create the Hyperscan database.

		Returns the database (:class:`hyperscan.Database`).
		)Úmode)r   r   ÚDatabaseÚHS_MODE_BLOCK© r0   r.   r#   zHyperscanPsBackend._make_dbà   s1   € ô 
Ð	Ð<¤¬OÐ <Ó<Ð	Ü	×	Ñ	¤×!8Ñ!8Ô	9Ð9r0   c                óˆ   — | j                   |   }|j                  }| j                  d   }||kD  r|j                  |f| _        y)zn
		Called on each match.

		*expr_id* (:class:`int`) is the expression id (index) of the matched
		pattern.
		r   N)r&   r4   r'   r3   )	r*   Úexpr_idÚ_fromÚ_toÚ_flagsÚ_contextÚexpr_datr4   Ú
prev_indexs	            r.   Ú
__on_matchzHyperscanPsBackend.__on_matchê   sE   € ð" �_‰_˜WÑ%€(Ø
�.‰.€%Ø�y‰y˜‰|€*Ø
ˆZÒØ× Ñ  %Ð(€4„9à	r0   )r   zSequence[RegexPattern]r   úOptional[bool]r   z Optional[Callable[[list], None]]ÚreturnÚNone)
r   úhyperscan.Databaser   r"   r   zlist[tuple[int, RegexPattern]]r   z%Optional[Callable[[list[int]], None]]r_   zlist[HyperscanExprDat])rL   r=   r_   z$tuple[Optional[bool], Optional[int]])r_   ra   )rV   ÚintrW   rb   rX   rb   rY   rb   rZ   r   r_   r^   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r/   Ústaticmethodr$   r
   rO   r#   rK   rT   r0   r.   r   r   '   sñ   „ ñð "&Ø15ñEà"ðEð ð	Eð
 /ðEð óEðN ðKØðKà	ðKð +ðKð 2ð	Kð
 òKó ðKðZ ò"ó ð"ð8 ò:ó ð:ðàðð 
ðð ð	ð
 ðð ðð ôr0   r   )rf   Ú
__future__r   Úcollections.abcr   Útypingr   r   r   r   ÚModuleNotFoundErrorÚpathspec.backendr   Úpathspec.patternr	   Úpathspec._typingr
   Ú_utilsr   Úbaser   Ú_baser   r   r   r   rT   r0   r.   ú<module>rr      sm   ðñõ #õ÷ñ ð
Ûõõõõõ÷ñ ôZ˜õ Zøð+ ò Ø‚ðús   šA ÁAÁA