o
    ?Zc                     @   sj   d 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ZG dd deZdS )zObject utilities.    )copy   )maybe_channel)NotBoundError)ChannelPromise)ObjectMaybeChannelBoundc                 C   s   | di |S N r
   )clskwargsr
   r
   D/var/www/chikooza/env/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__0   s   zObject.__reduce__c                 C   s   | j di |  S r	   )r'   r    r(   r
   r
   r   __copy__3   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__@   s   
zMaybeChannelBound.__call__c                 C   s   t | |S )z7Create copy of the instance that is bound to a channel.)r   
maybe_bindr0   r
   r
   r   r/   D   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_boundr0   r
   r
   r   r3   H   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)r4   r5   r6   r0   r
   r
   r   reviveP   s   zMaybeChannelBound.revivec                 C   s   dS )z(Callback called when the class is bound.Nr
   r(   r
   r
   r   r6   Z   s    zMaybeChannelBound.when_boundc                 C   s   |  t| jS r   )_repr_entityr"   r+   r(   r
   r
   r   __repr__]   s   zMaybeChannelBound.__repr__ c                 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+   r4   formatr1   
channel_id)r   itemr
   r
   r   r9   `   s   zMaybeChannelBound._repr_entityc                 C   s   | j o| jduS )z!Flag set if the channel is bound.N)r7   r5   r(   r
   r
   r   r4   g   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)r5   r   r=   r"   r+   r   r   r0   r
   r
   r   r1   l   s   
zMaybeChannelBound.channel)r;   )r+   r,   r-   r.   r5   r7   can_cache_declarationr2   r/   r3   r8   r6   r:   r9   propertyr4   r1   r
   r
   r
   r   r   7   s     


r   N)r.   r   
connectionr   
exceptionsr   utils.functionalr   __all__r   r   r   r   r
   r
   r
   r   <module>   s    #