U
    9%e
                  
   @   s   U d Z ddlZddlmZmZmZ ddlmZ ddlm	Z	 dd Z
eded	ef d
ZG dd deZeejddejddejddeejddeejdddZeed< dS )zFunction caching    N)AnyCallableTypeVar)Memory)FunctionMakerc                 C   s   t j|dt| |d|dS )Nz"return decfunc(%(shortsignature)s))Zdecfunc)__wrapped__)r   createdict)decfunc r   M/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/librosa/_cache.py_decorator_apply   s    r   _F.)boundc                   @   s   e Zd ZdZeedddZeeegef dddZ	eedd	d
dZ
eeed	ddZeeed	ddZeedd	ddZeedd	ddZdS )CacheManagera)  The librosa cache manager class wraps joblib.Memory
    with a __call__ attribute, so that it may act as a function.

    Additionally, it provides a caching level filter, so that
    different functions can be cached or not depending on the user's
    preference for speed vs. storage usage.
    )argskwargsc                 O   s"   | dd}t||| _|| _d S )Nlevel
   )popr   memoryr   )selfr   r   r   r   r   r   __init__    s    zCacheManager.__init__)r   returnc                    s    fdd}|S )z
        Cache with an explicitly defined level.

        Example usage:

        @cache(level=2)
        def semi_important_function(some_arguments):
            ...
        c                    s,   j jdk	r$j kr$tj j| S | S dS )z4Add an input/output cache to the specified function.N)r   locationr   r   cache)functionr   r   r   r   wrapper4   s    z&CacheManager.__call__.<locals>.wrapperr   )r   r   r   r   r   r   __call__)   s    zCacheManager.__call__N)r   r   r   c                 O   s   | j j|| dS )zClear the cacheN)r   clearr   r   r   r   r   r   r!   >   s    zCacheManager.clearc                 O   s   | j j||S )zEvaluate a function)r   evalr"   r   r   r   r#   B   s    zCacheManager.evalc                 O   s   | j j||S )z0Return the formatted representation of an object)r   formatr"   r   r   r   r$   F   s    zCacheManager.formatc                 O   s   | j j|| dS )zReduce the size of the cacheN)r   reduce_sizer"   r   r   r   r%   J   s    zCacheManager.reduce_sizec                 O   s   | j j|| dS )zRaise a warningN)r   warnr"   r   r   r   r&   N   s    zCacheManager.warn)__name__
__module____qualname____doc__r   r   intr   r   r    r!   r#   r$   r%   r&   r   r   r   r   r      s   	r   ZLIBROSA_CACHE_DIRZLIBROSA_CACHE_MMAPZLIBROSA_CACHE_COMPRESSFZLIBROSA_CACHE_VERBOSEZLIBROSA_CACHE_LEVELr   )Z	mmap_modecompressverboser   r   )r*   ostypingr   r   r   Zjoblibr   	decoratorr   r   r   objectr   environgetr+   r   __annotations__r   r   r   r   <module>   s   	=