o
    wvXj»  ã                   @   sŒ   d Z ddlmZmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ d	Zd
d„ Zdd„ ZG dd„ deƒZe
G dd„ deƒƒZdS )zObject utilities.é    )Úabsolute_importÚunicode_literals)Úcopyé   )Úmaybe_channel)ÚNotBoundError)Úpython_2_unicode_compatible)ÚChannelPromise)ÚObjectÚMaybeChannelBoundc                 C   s   | di |¤ŽS ©N© r   )ÚclsÚkwargsr   r   úK/var/www/html/myproject/venv/lib/python3.10/site-packages/kombu/abstract.pyÚunpickle_dict   s   r   c                 C   s   | S ©Nr   )Úvr   r   r   Ú_any   s   r   c                   @   s6   e Zd ZdZdZdd„ Zddd„Zdd	„ Zd
d„ ZdS )r
   zYCommon base class.

    Supports automatic kwargs->attributes handling, and cloning.
    r   c              	   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   )ÚattrsÚgetÚsetattrr   ÚgetattrÚAttributeError)ÚselfÚargsr   ÚnameÚtype_Úvaluer   r   r   Ú__init__   s   
ÿùzObject.__init__Fc                    s"   ‡fdd„‰ ‡ ‡fdd„ˆj D ƒS )Nc                    s2   ˆ rt | tƒr| jdd�S |r| d ur|| ƒS | S )NT©Úrecurse)Ú
isinstancer
   Úas_dict)ÚobjÚtyper    r   r   Úf*   s   zObject.as_dict.<locals>.fc                    s"   i | ]\}}|ˆ t ˆ|ƒ|ƒ“qS r   )r   )Ú.0Úattrr%   )r&   r   r   r   Ú
<dictcomp>.   s    ÿz"Object.as_dict.<locals>.<dictcomp>)r   )r   r!   r   )r&   r!   r   r   r#   )   s   ÿzObject.as_dictc                 C   s   t | j|  ¡ ffS r   )r   Ú	__class__r#   ©r   r   r   r   Ú
__reduce__2   s   zObject.__reduce__c                 C   s   | j di |  ¡ ¤ŽS r   )r*   r#   r+   r   r   r   Ú__copy__5   s   zObject.__copy__N)F)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r#   r,   r-   r   r   r   r   r
      s    
	r
   c                   @   sn   e Zd ZdZdZ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dS )r   z7Mixin for classes that can be bound to an AMQP channel.NFc                 C   s
   |   |¡S )z&`self(channel) -> self.bind(channel)`.)Úbind©r   Úchannelr   r   r   Ú__call__C   s   
zMaybeChannelBound.__call__c                 C   s   t | ƒ |¡S )z7Create copy of the instance that is bound to a channel.)r   Ú
maybe_bindr3   r   r   r   r2   G   s   zMaybeChannelBound.bindc                 C   s&   | j s|rt|ƒ| _|  ¡  d| _| S )z.Bind instance to channel if not already bound.T)Úis_boundr   Ú_channelÚ
when_boundÚ	_is_boundr3   r   r   r   r6   K   s
   

zMaybeChannelBound.maybe_bindc                 C   s   | j r|| _|  ¡  dS dS )zyRevive channel after the connection has been re-established.

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

        N)r7   r8   r9   r3   r   r   r   ÚreviveS   s   þzMaybeChannelBound.revivec                 C   s   dS )z(Callback called when the class is bound.Nr   r+   r   r   r   r9   ]   s   zMaybeChannelBound.when_boundc                 C   s   |   t| ƒj¡S r   )Ú_repr_entityr%   r.   r+   r   r   r   Ú__repr__a   s   zMaybeChannelBound.__repr__Ú c                 C   s8   |pt | ƒj}| jrd |pt | ƒj| jj¡S d |¡S )Nz<{0} bound to chan:{1}>z<unbound {0}>)r%   r.   r7   Úformatr4   Ú
channel_id)r   Úitemr   r   r   r<   d   s   ÿ
zMaybeChannelBound._repr_entityc                 C   s   | j o| jduS )z!Flag set if the channel is bound.N)r:   r8   r+   r   r   r   r7   k   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 {0} not bound to a channel)r8   r   r?   r%   r.   r"   r	   r3   r   r   r   r4   p   s   ÿÿ
zMaybeChannelBound.channel)r>   )r.   r/   r0   r1   r8   r:   Úcan_cache_declarationr5   r2   r6   r;   r9   r=   r<   Úpropertyr7   r4   r   r   r   r   r   9   s     


r   N)r1   Ú
__future__r   r   r   Ú
connectionr   Ú
exceptionsr   Úfiver   Úutils.functionalr	   Ú__all__r   r   Úobjectr
   r   r   r   r   r   Ú<module>   s    #