o
    —¨Êh­  ã                   @  sî   d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	 ddl
mZ ddlmZ eeegef ZG d	d
„ d
eƒZG dd„ dƒZeƒ Z	 ejZ	 ejZ	 ejZddd„Zddd„Zeƒ  eƒ  e d¡ edƒD ]\ZZeejge¢R Ž  qgdS )zPattern matching registry.é    )Úannotations)Úfnmatch)Úmatch)ÚCallableÚcasté   )Úentrypoints)Úbytes_to_strc                   @  s   e Zd ZdZdS )ÚMatcherNotInstalledzMatcher not installed/found.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   ú?/var/www/html/env/lib/python3.10/site-packages/kombu/matcher.pyr
      s    r
   c                   @  sR   e Zd ZdZeZdgZddd„Zddd„Zddd„Zddd„Z			dddd„Z
dS ) ÚMatcherRegistryz#Pattern matching function registry.ÚpcreÚreturnÚNonec                 C  s   i | _ d | _d S )N)Ú	_matchersÚ_default_matcher)Úselfr   r   r   Ú__init__   s   
zMatcherRegistry.__init__ÚnameÚstrÚmatcherÚMatcherFunctionc                 C  s   || j |< dS )z$Add matcher by name to the registry.N)r   )r   r   r   r   r   r   Úregister   s   zMatcherRegistry.registerc                 C  s2   z	| j  |¡ W dS  ty   |  d|› �¡‚w )z)Remove matcher by name from the registry.úNo matcher installed for N)r   ÚpopÚKeyErrorr
   ©r   r   r   r   r   Ú
unregister!   s   ÿÿzMatcherRegistry.unregisterc                 C  s2   z	| j | | _W dS  ty   |  d|› �¡‚w )aH  Set the default matching method.

        :param name: The name of the registered matching method.
            For example, `glob` (default), `pcre`, or any custom
            methods registered using :meth:`register`.

        :raises MatcherNotInstalled: If the matching method requested
            is not available.
        r   N)r   r   r    r
   r!   r   r   r   Ú_set_default_matcher*   s   
ÿÿz$MatcherRegistry._set_default_matcherNÚdataÚbytesÚpatternú
str | NoneÚmatcher_kwargsúdict[str, str] | NoneÚboolc                 C  sp   |r| j  |¡s|  d|› �¡‚| j |pd }|| jv r%t|ƒ}t|ƒ}nt|ƒ}t|ƒ}|||fi |p5i ¤ŽS )zCall the matcher.r   Úglob)r   Úgetr
   Úmatcher_pattern_firstr	   )r   r$   r&   r   r(   Ú
match_funcÚ	first_argÚ
second_argr   r   r   r   ;   s   ÿ

zMatcherRegistry.match©r   r   )r   r   r   r   r   r   )r   r   r   r   )NN)
r$   r%   r&   r%   r   r'   r(   r)   r   r*   )r   r   r   r   r
   r-   r   r   r"   r#   r   r   r   r   r   r      s    



	ûr   r   r   c                   C  s   t  dt¡ dS )z$Register glob into default registry.r+   N)Úregistryr   r   r   r   r   r   Úregister_glob}   s   r3   c                   C  s   t  dtttƒ¡ dS )z$Register pcre into default registry.r   N)r2   r   r   r   Úrematchr   r   r   r   Úregister_pcre‚   s   r5   r+   zkombu.matchersNr1   )r   Ú
__future__r   r   Úrer   r4   Útypingr   r   Úutils.compatr   Úutils.encodingr	   r   r*   r   Ú	Exceptionr
   r   r2   r   r"   r3   r5   r#   ÚepÚargsr   r   r   r   r   Ú<module>   s2    ?


ÿ