o
    wvXjÚ  ã                   @   s(   d Z ddlmZmZ G dd„ deƒZdS )zObject Utilities.é    )Úabsolute_importÚunicode_literalsc                   @   sJ   e Zd ZdZddd„Zddd„Zdd„ Zeƒ fd	d
„Zdd„ Z	dd„ Z
dS )Úcached_propertyaÇ  Cached property descriptor.

    Caches the return value of the get method on first call.

    Examples:
        .. code-block:: python

            @cached_property
            def connection(self):
                return Connection()

            @connection.setter  # Prepares stored value
            def connection(self, value):
                if value is None:
                    raise TypeError('Connection must be a connection')
                return value

            @connection.deleter
            def connection(self, value):
                # Additional action to do at del(self.attr)
                if value is not None:
                    print('Connection {0!r} deleted'.format(value)
    Nc                 C   s2   || _ || _|| _|p|j| _|j| _|j| _d S ©N)Ú_cached_property__getÚ_cached_property__setÚ_cached_property__delÚ__doc__Ú__name__Ú
__module__)ÚselfÚfgetÚfsetÚfdelÚdoc© r   úP/var/www/html/myproject/venv/lib/python3.10/site-packages/kombu/utils/objects.pyÚ__init__   s   zcached_property.__init__c                 C   sH   |d u r| S z|j | j W S  ty#   |  |¡ }|j | j< | Y S w r   )Ú__dict__r
   ÚKeyErrorr   )r   ÚobjÚtypeÚvaluer   r   r   Ú__get__&   s   þzcached_property.__get__c                 C   s2   |d u r| S | j d ur|   ||¡}||j| j< d S r   )r   r   r
   )r   r   r   r   r   r   Ú__set__/   s
   
zcached_property.__set__c                 C   sF   |d u r| S |j  | j|¡}| jd ur||ur!|  ||¡ d S d S d S r   )r   Úpopr
   r   )r   r   Ú	_sentinelr   r   r   r   Ú
__delete__6   s   ÿzcached_property.__delete__c                 C   s   |   | j|| j¡S r   )Ú	__class__r   r   )r   r   r   r   r   Úsetter=   ó   zcached_property.setterc                 C   s   |   | j| j|¡S r   )r   r   r   )r   r   r   r   r   Údeleter@   r    zcached_property.deleter)NNNNr   )r
   r   Ú__qualname__r	   r   r   r   Úobjectr   r   r!   r   r   r   r   r      s    

	r   N)r	   Ú
__future__r   r   r#   r   r   r   r   r   Ú<module>   s    