o
    tBh                     @   s4   d dl Z ddlmZ edfddZedfddZdS )    N   )hashkeyc                        fdd}|S )z_Decorator to wrap a function with a memoizing callable that saves
    results in a cache.

    c                    sN   d u r fdd}nd u r fdd}n	 fdd}t | S )Nc                     s    | i |S N )argskwargsfuncr   l/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/cachetools/decorators.pywrapper   s   z*cached.<locals>.decorator.<locals>.wrapperc                     s^   | i |}z | W S  t y   Y nw | i |}z| |< W |S  ty.   Y |S w r   KeyError
ValueErrorr   r   kv)cacher
   keyr   r   r      s   

c                     s   | i |}z  | W  d    W S 1 sw   Y  W n	 t y)   Y nw | i |}z  ||W  d    W S 1 sFw   Y  W d S  tyX   | Y S w r   r   
setdefaultr   r   )r   r
   r   lockr   r   r   #   s    &
(	functoolsupdate_wrapper)r
   r   r   r   r   r	   r   	decorator   s   zcached.<locals>.decoratorr   r   r   r   r   r   r   r   cached   s   (r   c                    r   )zoDecorator to wrap a class or instance method with a memoizing
    callable that saves results in a cache.

    c                    s8   d u r fdd}n	 fdd}t | S )Nc                    s    | }|d u r| g|R i |S |i |}z|| W S  t y(   Y nw | g|R i |}z|||< W |S  tyE   Y |S w r   r   selfr   r   cr   r   )r   r   methodr   r   r   @   s"   

z0cachedmethod.<locals>.decorator.<locals>.wrapperc                    s    | }|d u r| g|R i |S |i |}z|  || W  d    W S 1 s/w   Y  W n	 t y>   Y nw | g|R i |}z|  |||W  d    W S 1 saw   Y  W d S  tys   | Y S w r   r   r   )r   r   r   r"   r   r   r   R   s&   
&

(r   )r"   r   r   )r"   r   r   =   s   zcachedmethod.<locals>.decoratorr   r   r   r   r   cachedmethod7   s   )r#   )r   keysr   r   r#   r   r   r   r   <module>   s    1