
    IhJ                        d Z ddlmZ ddlmZ ddlmZmZmZmZ ddl	m
Z
 ddlmZ ddlmZ erdd	lmZ dd
lmZ dZ ed      Z edd      Z edd      Z	 	 	 	 	 	 ddZddZ G d d      Z G d de      Zy)zObject utilities.    )annotations)copy)TYPE_CHECKINGAnyCallableTypeVar   )maybe_channel)NotBoundError)ChannelPromise)
Connection)Channel)ObjectMaybeChannelBound_T_ObjectTyper   )bound_MaybeChannelBoundTyper   c                     | di |S N r   )clskwargss     G/var/www/html/planif/env/lib/python3.12/site-packages/kombu/abstract.pyunpickle_dictr      s     ==    c                    | S Nr   )vs    r   _anyr        s    Hr   c                  B    e Zd ZU dZdZded<   d
dZdddZddZddZ	y	)r   zYCommon base class.

    Supports automatic kwargs->attributes handling, and cloning.
    r   ztuple[tuple[str, Any], ...]attrsc                    | j                   D ]A  \  }}|j                  |      }|t        | | |xs t        |             5	 t	        | |       C y # t
        $ r t        | |d        Y ]w xY wr   )r"   getsetattrr    getattrAttributeError)selfargsr   nametype_values         r   __init__zObject.__init__,   sp    :: 	.KD%JJt$E d]U]dE$:;.D$'	. & .D$-.s   AA+*A+c                    ddfd}| j                   D ci c]  \  }}| |t        | |      |       c}}S c c}}w )Nc                h    r"t        | t              r| j                  d      S |r
|  ||       S | S )NT)recurse)
isinstancer   as_dict)objtyper0   s     r   fzObject.as_dict.<locals>.f8   s5    :c62{{4{00 $49AcAr   r   )r3   r   r4   zCallable[[Any], Any] | Nonereturnr   )r"   r&   )r(   r0   r5   attrr4   s    `   r   r2   zObject.as_dict7   sE    	B
 BF
3=4D!GD$'..
 	
 
s   :c                F    t         | j                  | j                         ffS r   )r   	__class__r2   r(   s    r   
__reduce__zObject.__reduce__@   s     t~~t||~>>>r   c                B     | j                   di | j                         S r   )r9   r2   r:   s    r   __copy__zObject.__copy__F   s    t~~///r   N)r)   r   r   r   r6   None)F)r0   boolr6   dict[str, Any])r(   r   r6   zktuple[Callable[[type[_ObjectType], dict[str, Any]], _ObjectType], tuple[type[_ObjectType], dict[str, Any]]])r(   r   r6   r   )
__name__
__module____qualname____doc__r"   __annotations__r-   r2   r;   r=   r   r   r   r   r   $   s(    
 *,E&+	.
?0r   c                      e Zd ZU dZdZded<   dZdZ	 	 	 	 	 	 ddZ	 	 	 	 	 	 ddZ		 	 	 	 	 	 ddZ
dd	Zdd
ZddZdddZedd       Zedd       Zy)r   z7Mixin for classes that can be bound to an AMQP channel.NzChannel | None_channelFc                $    | j                  |      S )z&`self(channel) -> self.bind(channel)`.)bindr(   channels     r   __call__zMaybeChannelBound.__call__S   s     yy!!r   c                6    t        |       j                  |      S )z7Create copy of the instance that is bound to a channel.)r   
maybe_bindrJ   s     r   rI   zMaybeChannelBound.bindY   s     Dz$$W--r   c                p    | j                   s)|r't        |      | _        | j                          d| _        | S )z.Bind instance to channel if not already bound.T)is_boundr
   rG   
when_bound	_is_boundrJ   s     r   rN   zMaybeChannelBound.maybe_bind_   s/     }})'2DMOO!DNr   c                L    | j                   r|| _        | j                          yy)zyRevive channel after the connection has been re-established.

        Used by :meth:`~kombu.Connection.ensure`.

        N)rP   rG   rQ   rJ   s     r   revivezMaybeChannelBound.revivei   s!     ==#DMOO r   c                     y)z(Callback called when the class is bound.Nr   r:   s    r   rQ   zMaybeChannelBound.when_bounds   s    r   c                J    | j                  t        |       j                        S r   )_repr_entityr4   rA   r:   s    r   __repr__zMaybeChannelBound.__repr__v   s      d!4!455r   c                    |xs t        |       j                  }| j                  r=dj                  |xs t        |       j                  | j                  j
                        S d| dS )Nz<{} bound to chan:{}>z	<unbound >)r4   rA   rP   formatrK   
channel_id)r(   items     r   rW   zMaybeChannelBound._repr_entityy   s_    *tDz**==*11+T
++T\\-D-DF F4&""r   c                :    | j                   xr | j                  duS )z!Flag set if the channel is bound.N)rR   rG   r:   s    r   rP   zMaybeChannelBound.is_bound   s     ~~;$--t";;r   c                    | j                   }|-t        dj                  t        |       j                              t        |t              r |       x}| _         |S )z'Current channel if the object is bound.z.Can't call method on {} not bound to a channel)rG   r   r[   r4   rA   r1   r   rJ   s     r   rK   zMaybeChannelBound.channel   sY     --?@GGJ'')* * g~.&-i/Gdmr   )r(   r   rK   zChannel | Connectionr6   r   )rK   r   r6   r>   )r6   r>   )r6   str) )r]   r`   r6   r`   )r6   r?   )r6   r   )rA   rB   rC   rD   rG   rE   rR   can_cache_declarationrL   rI   rN   rT   rQ   rX   rW   propertyrP   rK   r   r   r   r   r   J   s    A#Hn#I ""$"0D"	".$.0D.	.$0D	76# < < 	 	r   N)r   ztype[_ObjectType]r   r@   r6   r   )r   r   r6   r   )rD   
__future__r   r   typingr   r   r   r   
connectionr
   
exceptionsr   utils.functionalr   kombu.connectionr   kombu.transport.virtualr   __all__r   r   r   r   r    r   r   r   r   r   <module>rl      s     "  8 8 % % ,+/ *T]m84 $7 
	$2#0 #0LE Er   