o
    Df                     @  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   F/home/ubuntu/webapp/venv/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    ?


