o
    tBh                  	   @   s   d Z dZdZdZddlmZ ddlmZ ddlZzddlZW n e	e
fy+   dZY nw G dd	 d	eZG d
d deZG dd deZeZeZG dd deZeZeZdS )zDaniel Greenfeldzpydanny@gmail.comz1.5.2BSD    )wraps)timeNc                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	cached_propertya   
    A property that is only computed once per instance and then replaces itself
    with an ordinary attribute. Deleting the attribute resets the property.
    Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
    c                 C   s   t |d| _|| _d S N__doc__)getattrr   funcselfr	    r   f/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/cached_property.py__init__   s   
zcached_property.__init__c                 C   sB   |d u r| S t rt | jr| |S | | }|j| jj< |S N)asyncioiscoroutinefunctionr	   _wrap_in_coroutine__dict____name__)r   objclsvaluer   r   r   __get__   s   
zcached_property.__get__c                    s"   t  tj fdd}| S )Nc                     s"   t  } |  jjj< | S r   )r   ensure_futurer	   r   r   )futurer   r   r   r   wrapper(   s   z3cached_property._wrap_in_coroutine.<locals>.wrapper)r   r   	coroutine)r   r   r   r   r   r   r   '   s   z"cached_property._wrap_in_coroutineN)r   
__module____qualname__r   r   r   r   r   r   r   r   r      s
    
r   c                   @   s    e Zd ZdZdd Zdd ZdS )threaded_cached_property
    A cached_property version for use in environments where multiple threads
    might concurrently try to access the property.
    c                 C   s    t |d| _|| _t | _d S r   )r   r   r	   	threadingRLocklockr
   r   r   r   r   8   s   z!threaded_cached_property.__init__c              
   C   s   |d u r| S |j }| jj}| j' z|| W W  d    S  ty6   ||| | Y W  d    S w 1 s:w   Y  d S r   )r   r	   r   r$   KeyError
setdefault)r   r   r   obj_dictnamer   r   r   r   =   s   z threaded_cached_property.__get__N)r   r   r   r   r   r   r   r   r   r   r    2   s    r    c                   @   sB   e Zd ZdZdddZdd Zdd Zd	d
 Zdd Zdd Z	dS )cached_property_with_ttlz
    A property that is only computed once per instance and then replaces itself
    with an ordinary attribute. Setting the ttl to a number expresses how long
    the property will last before being timed out.
    Nc                 C   s*   t |r	|}d }nd }|| _| | d S r   )callablettl_prepare_func)r   r+   r	   r   r   r   r   T   s   z!cached_property_with_ttl.__init__c                 C   s   |  | | S r   )r,   r
   r   r   r   __call__]   s   
z!cached_property_with_ttl.__call__c           	      C   sx   |d u r| S t  }|j}| j}z|| \}}W n	 ty    Y nw | jo*| j|| k }|s/|S | |}||f||< |S r   )r   r   r   r%   r+   r	   )	r   r   r   nowr'   r(   r   last_updatedttl_expiredr   r   r   r   a   s    
z cached_property_with_ttl.__get__c                 C   s   |j | jd  d S r   )r   popr   )r   r   r   r   r   
__delete__u   s   z#cached_property_with_ttl.__delete__c                 C   s   |t  f|j| j< d S r   )r   r   r   )r   r   r   r   r   r   __set__x   s   z cached_property_with_ttl.__set__c                 C   s*   || _ |r|j| _|j| _|j| _d S d S r   )r	   r   r   r   r
   r   r   r   r,   {   s   z&cached_property_with_ttl._prepare_funcr   )
r   r   r   r   r   r-   r   r2   r3   r,   r   r   r   r   r)   M   s    
	r)   c                       s.   e Zd ZdZd fdd	Z fddZ  ZS )!threaded_cached_property_with_ttlr!   Nc                    s   t t| | t | _d S r   )superr4   r   r"   r#   r$   )r   r+   	__class__r   r   r      s   z*threaded_cached_property_with_ttl.__init__c                    s<   | j  tt| ||W  d    S 1 sw   Y  d S r   )r$   r5   r4   r   )r   r   r   r6   r   r   r      s   $z)threaded_cached_property_with_ttl.__get__r   )r   r   r   r   r   r   __classcell__r   r   r6   r   r4      s    r4   )
__author__	__email____version____license__	functoolsr   r   r"   r   ImportErrorSyntaxErrorobjectr   r    r)   cached_property_ttltimed_cached_propertyr4   threaded_cached_property_ttltimed_threaded_cached_propertyr   r   r   r   <module>   s(    7