
    ^f                        d Z ddlmZ ddlZddlmZ  G d d          Z G d de          Z G d	 d
e          Z G d de          Z	eee	dZ
dS )zVirtual AMQ Exchange.

Implementations of the standard exchanges defined
by the AMQ protocol  (excluding the `headers` exchange).
    )annotationsN)escape_regexc                  .    e Zd ZdZdZd Zd Zd Zd ZdS )ExchangeTypezBase class for exchanges.

    Implements the specifics for an exchange type.

    Arguments:
    ---------
        channel (ChannelT): AMQ Channel.
    Nc                    || _         d S N)channel)selfr	   s     R/var/www/html/env/lib/python3.11/site-packages/kombu/transport/virtual/exchange.py__init__zExchangeType.__init__   s        c                     t          d          )zLookup all queues matching `routing_key` in `exchange`.

        Returns
        -------
            str: queue name, or 'default' if no queues matched.
        zsubclass responsibility)NotImplementedErrorr
   tableexchangerouting_keydefaults        r   lookupzExchangeType.lookup   s     "";<<<r   c                    |d|fS )zPrepare queue-binding.

        Returns
        -------
            Tuple[str, Pattern, str]: of `(routing_key, regex, queue)`
                to be stored for bindings to this exchange.
        N r
   queuer   r   	argumentss        r   prepare_bindzExchangeType.prepare_bind&   s     D%''r   c                j    ||d         k    o'||d         k    o||d         k    o|pi |d         pi k    S )z3Return true if `prev` and `exchange` is equivalent.typedurableauto_deleter   r   )r
   prevr   r   r   r   r   s          r   
equivalentzExchangeType.equivalent0   sV     V$ ?4	?*?tM22? bd;&7&=2>	@r   )	__name__
__module____qualname____doc__r   r   r   r   r!   r   r   r   r   r      sf          D  = = =( ( (@ @ @ @ @r   r   c                  "    e Zd ZdZdZd Zd ZdS )DirectExchangezTDirect exchange.

    The `direct` exchange routes based on exact routing keys.
    directc                     fd|D             S )Nc                (    h | ]\  }}}|k    |S r   r   ).0rkey_r   r   s       r   	<setcomp>z(DirectExchange.lookup.<locals>.<setcomp>B   s4     
 
 
$dAu{"" """r   r   r   s      ` r   r   zDirectExchange.lookupA   s.    
 
 
 
(-
 
 
 	
r   c                h    | j         j        }| j         j        } |||          D ]} |||fi | d S r   )r	   _lookup_put)r
   messager   r   kwargsr0   r1   r   s           r   deliverzDirectExchange.deliverG   sX    ,&| WX{33 	+ 	+ED**6****	+ 	+r   Nr"   r#   r$   r%   r   r   r4   r   r   r   r'   r'   9   sC         
 D
 
 
+ + + + +r   r'   c                  B    e Zd ZdZdZdddZi Zd Zd Zd Z	d	 Z
d
 ZdS )TopicExchangezTopic exchange.

    The `topic` exchange routes messages based on words separated by
    dots, using wildcard characters ``*`` (any single word), and ``#``
    (one or more words).
    topicz.*?[^\.]z.*?)*#c                $      fd|D             S )Nc                H    h | ]\  }}}                     |          |S r   )_match)r+   r,   patternr   r   r
   s       r   r.   z'TopicExchange.lookup.<locals>.<setcomp>`   sC     
 
 
*dGU{{7K00

 
 
r   r   r   s   `  ` r   r   zTopicExchange.lookup_   s4    
 
 
 
 
.3
 
 
 	
r   c                    | j         j        }| j         j        }| j         j        fd |||          D             D ]} |||fi | d S )Nc                $    g | ]}|r|k    
|S r   r   )r+   q
deadletters     r   
<listcomp>z)TopicExchange.deliver.<locals>.<listcomp>i   s1     0 0 0A0 J .r   )r	   r0   r1   deadletter_queue)	r
   r2   r   r   r3   r0   r1   r   rB   s	           @r   r4   zTopicExchange.delivere   s    ,&| \2
0 0 0 0;!?!? 0 0 0 	+ 	+ED**6****	+ 	+r   c                2    ||                      |          |fS r   )key_to_patternr   s        r   r   zTopicExchange.prepare_bindm   s    D//<<eCCr   c                     dd                      fdt          |d                              d          D                       z  S )z0Get the corresponding regex for any routing key.z^%s$z\.c              3  N   K   | ]}j                             ||          V   d S r   )	wildcardsget)r+   wordr
   s     r   	<genexpr>z/TopicExchange.key_to_pattern.<locals>.<genexpr>r   sI       $
 $
 NtT**$
 $
 $
 $
 $
 $
r   z.#*.)joinr   split)r
   r,   s   ` r   rF   zTopicExchange.key_to_patternp   s^     $
 $
 $
 $
$T51177<<$
 $
 $
 
 
  	r   c                    	 | j         |         }n9# t          $ r, t          j        |t          j                  x}| j         |<   Y nw xY w|                    |          S )zMatch regular expression (cached).

        Same as :func:`re.match`, except the regex is compiled and cached,
        then reused on subsequent matches with the same pattern.
        )	_compiledKeyErrorrecompileUmatch)r
   r>   stringcompileds       r   r=   zTopicExchange._matchw   sl    	K~g.HH 	K 	K 	K13GRT1J1JJHt~g...	K~~f%%%s    3AAN)r"   r#   r$   r%   r   rI   rQ   r   r4   r   rF   r=   r   r   r   r7   r7   N   s          D " I I
 
 
+ + +D D D  
& 
& 
& 
& 
&r   r7   c                  "    e Zd ZdZdZd Zd ZdS )FanoutExchangea  Fanout exchange.

    The `fanout` exchange implements broadcast messaging by delivering
    copies of all messages to all queues bound to the exchange.

    To support fanout the virtual channel needs to store the table
    as shared state.  This requires that the `Channel.supports_fanout`
    attribute is set to true, and the `Channel._queue_bind` and
    `Channel.get_table` methods are implemented.

    See Also
    --------
        the redis backend for an example implementation of these methods.
    fanoutc                    d |D             S )Nc                    h | ]\  }}}|	S r   r   )r+   r-   r   s      r   r.   z(FanoutExchange.lookup.<locals>.<setcomp>   s    ///+!Q///r   r   r   s        r   r   zFanoutExchange.lookup   s    //////r   c                L    | j         j        r | j         j        |||fi | d S d S r   )r	   supports_fanout_put_fanout)r
   r2   r   r   r3   s        r   r4   zFanoutExchange.deliver   sP    <' 	:$DL$';: :28: : : : :	: 	:r   Nr5   r   r   r   rZ   rZ      sC          D0 0 0: : : : :r   rZ   )r(   r8   r[   )r%   
__future__r   rS   kombu.utils.textr   r   r'   r7   rZ   STANDARD_EXCHANGE_TYPESr   r   r   <module>rd      s    # " " " " " 				 ) ) ) ) ) )(@ (@ (@ (@ (@ (@ (@ (@V+ + + + +\ + + +*3& 3& 3& 3& 3&L 3& 3& 3&l: : : : :\ : : ::     r   