o
    ?Zœc2  ã                   @   s¾   d Z ddlmZ ddlmZ ddlmZ ddlm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„ Zdd„ Zeƒ  eƒ  e d¡ edƒD ]\ZZeejge¢R Ž  qOdS )zPattern matching registry.é    )Úfnmatch)Úmatché   )Ú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   úC/var/www/chikooza/env/lib/python3.10/site-packages/kombu/matcher.pyr   
   s    r   c                   @   sD   e Zd ZdZeZdgZdd„ Zdd„ Zdd„ Zd	d
„ Z	ddd„Z
dS )ÚMatcherRegistryz#Pattern matching function registry.Úpcrec                 C   s   i | _ d | _d S )N)Ú	_matchersÚ_default_matcher)Úselfr   r   r   Ú__init__   s   
zMatcherRegistry.__init__c                 C   s   || j |< dS )z$Add matcher by name to the registry.N)r   )r   ÚnameÚmatcherr   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_matcherNc                 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   ÚdataÚpatternr   Úmatcher_kwargsÚ
match_funcÚ	first_argÚ
second_argr   r   r   r   6   s   ÿ

zMatcherRegistry.match)NN)r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r      s    	r   c                   C   ó   t  dt¡ dS )z$Register glob into default registry.r   N)Úregistryr   r   r   r   r   r   Úregister_globr   ó   r(   c                   C   r&   )z$Register pcre into default registry.r   N)r'   r   Úrematchr   r   r   r   Úregister_pcrew   r)   r+   r   zkombu.matchersN)r   r   Úrer   r*   Úutils.compatr   Úutils.encodingr   Ú	Exceptionr   r   r'   r   r   r(   r+   r   ÚepÚargsr   r   r   r   r   Ú<module>   s,    9
ÿ