o
    a&i
                  
   @   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   9C:\wamp64\www\opt\env\Lib\site-packages\librosa/_cache.py_decorator_apply   s   r   _F.)boundc                   @   s   e Zd ZdZdedefddZdedeegef fdd	Z	dededd
fddZ
dededefddZdededefddZdededd
fddZdededd
f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|i || _|| _d S )Nlevel
   )popr   memoryr   )selfr   r   r   r   r   r   __init__    s   
zCacheManager.__init__r   returnc                    s    fdd}|S )zuExample usage:

        @cache(level=2)
        def semi_important_function(some_arguments):
            ...
        c                    s(   j jdurj krtj j| S | S )zVDecorator function.  Adds an input/output cache to
            the specified function.N)r   locationr   r   cache)functionr   r   r   r   wrapper1   s   z&CacheManager.__call__.<locals>.wrapperr   )r   r   r   r   r   r   __call__)   s   	zCacheManager.__call__Nc                 O      | j j|i | d S N)r   clearr   r   r   r   r   r   r#   <      zCacheManager.clearc                 O      | j j|i |S r"   )r   evalr$   r   r   r   r'   ?      zCacheManager.evalc                 O   r&   r"   )r   formatr$   r   r   r   r)   B   r(   zCacheManager.formatc                 O   r!   r"   )r   reduce_sizer$   r   r   r   r*   E   r%   zCacheManager.reduce_sizec                 O   r!   r"   )r   warnr$   r   r   r   r+   H   r%   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getr0   r   __annotations__r   r   r   r   <module>   s   	6