o
    —¨ÊhJ  ã                   @  sÎ   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d�Zeddd�Zddd„Zd dd„ZG dd„ dƒZG dd„ deƒZdS )!zObject utilities.é    )Úannotations)Úcopy)ÚTYPE_CHECKINGÚAnyÚCallableÚTypeVaré   )Úmaybe_channel)ÚNotBoundError)ÚChannelPromise)Ú
Connection)ÚChannel)ÚObjectÚMaybeChannelBoundÚ_TÚ_ObjectTyper   )ÚboundÚ_MaybeChannelBoundTyper   Úclsútype[_ObjectType]Úkwargsúdict[str, Any]Úreturnc                 C  s   | di |¤ŽS ©N© r   )r   r   r   r   ú@/var/www/html/env/lib/python3.10/site-packages/kombu/abstract.pyÚunpickle_dict   s   r   Úvc                 C  s   | S ©Nr   )r   r   r   r   Ú_any    s   r   c                   @  sH   e Zd ZU dZdZded< dd
d„Zdddd„Zddd„Zddd„Z	dS )r   zYCommon base class.

    Supports automatic kwargs->attributes handling, and cloning.
    r   ztuple[tuple[str, Any], ...]ÚattrsÚargsr   r   r   ÚNonec              	   O  sh   | j D ].\}}| |¡}|d urt| ||pt|ƒƒ qzt| |ƒ W q ty1   t| |d ƒ Y qw d S r   )r    ÚgetÚsetattrr   ÚgetattrÚAttributeError)Úselfr!   r   ÚnameÚtype_Úvaluer   r   r   Ú__init__,   s   
ÿùzObject.__init__FÚrecurseÚboolr   c                   s&   d
d‡fdd„‰ ‡ ‡fdd	„ˆj D ƒS )NÚobjr   ÚtypeúCallable[[Any], Any] | Noner   c                   s2   ˆ rt | tƒr| jdd�S |r| d ur|| ƒS | S )NT©r,   )Ú
isinstancer   Úas_dict)r.   r/   r1   r   r   Úf8   s   zObject.as_dict.<locals>.fc                   s"   i | ]\}}|ˆ t ˆ|ƒ|ƒ“qS r   )r%   )Ú.0Úattrr/   )r4   r'   r   r   Ú
<dictcomp><   s    ÿz"Object.as_dict.<locals>.<dictcomp>r   )r.   r   r/   r0   r   r   )r    )r'   r,   r   )r4   r,   r'   r   r3   7   s   ÿzObject.as_dictr'   r   úktuple[Callable[[type[_ObjectType], dict[str, Any]], _ObjectType], tuple[type[_ObjectType], dict[str, Any]]]c                 C  s   t | j|  ¡ ffS r   )r   Ú	__class__r3   ©r'   r   r   r   Ú
__reduce__@   s   zObject.__reduce__c                 C  s   | j di |  ¡ ¤ŽS r   )r9   r3   r:   r   r   r   Ú__copy__F   s   zObject.__copy__N)r!   r   r   r   r   r"   )F)r,   r-   r   r   )r'   r   r   r8   )r'   r   r   r   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r    Ú__annotations__r+   r3   r;   r<   r   r   r   r   r   $   s   
 

	c                   @  sŠ   e Zd ZU dZdZded< dZdZd#dd„Zd#dd„Z	d#dd„Z
d$dd„Zd%dd„Zd&dd„Zd'd(dd„Zed)dd „ƒZed*d!d"„ƒZdS )+r   z7Mixin for classes that can be bound to an AMQP channel.NzChannel | NoneÚ_channelFr'   r   ÚchannelúChannel | Connectionr   c                 C  s
   |   |¡S )z&`self(channel) -> self.bind(channel)`.)Úbind©r'   rC   r   r   r   Ú__call__S   s   
zMaybeChannelBound.__call__c                 C  s   t | ƒ |¡S )z7Create copy of the instance that is bound to a channel.)r   Ú
maybe_bindrF   r   r   r   rE   Y   s   zMaybeChannelBound.bindc                 C  s&   | j s|rt|ƒ| _|  ¡  d| _| S )z.Bind instance to channel if not already bound.T)Úis_boundr	   rB   Ú
when_boundÚ	_is_boundrF   r   r   r   rH   _   s
   

zMaybeChannelBound.maybe_bindr   r"   c                 C  s   | j r|| _|  ¡  dS dS )zyRevive channel after the connection has been re-established.

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

        N)rI   rB   rJ   rF   r   r   r   Úrevivei   s   þzMaybeChannelBound.revivec                 C  s   dS )z(Callback called when the class is bound.Nr   r:   r   r   r   rJ   s   s    zMaybeChannelBound.when_boundÚstrc                 C  s   |   t| ƒj¡S r   )Ú_repr_entityr/   r=   r:   r   r   r   Ú__repr__v   s   zMaybeChannelBound.__repr__Ú Úitemc                 C  s:   |pt | ƒj}| jrd |pt | ƒj| jj¡S d|› d�S )Nz<{} bound to chan:{}>z	<unbound ú>)r/   r=   rI   ÚformatrC   Ú
channel_id)r'   rQ   r   r   r   rN   y   s   ÿzMaybeChannelBound._repr_entityr-   c                 C  s   | j o| jduS )z!Flag set if the channel is bound.N)rK   rB   r:   r   r   r   rI   €   s   zMaybeChannelBound.is_boundc                 C  s<   | j }|du rtd t| ƒj¡ƒ‚t|tƒr|ƒ  }| _ |S )z'Current channel if the object is bound.Nz.Can't call method on {} not bound to a channel)rB   r
   rS   r/   r=   r2   r   rF   r   r   r   rC   …   s   ÿÿ
zMaybeChannelBound.channel)r'   r   rC   rD   r   r   )rC   r   r   r"   )r   r"   )r   rM   )rP   )rQ   rM   r   rM   )r   r-   )r   r   )r=   r>   r?   r@   rB   rA   rK   Úcan_cache_declarationrG   rE   rH   rL   rJ   rO   rN   ÚpropertyrI   rC   r   r   r   r   r   J   s    
 







N)r   r   r   r   r   r   )r   r   r   r   )r@   Ú
__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   r   Ú<module>   s(    ÿ

&