o
    môjá
  ã                
   @   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   ú_/var/www/html/academy/tools/voices/clone/sv-venv/lib/python3.10/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 )z¯
        Cache with an explicitly defined level.

        Example 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 )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__Nc                 O   ó   | j j|i |¤Ž dS )zClear the cacheN)r   Úclear©r   r   r   r   r   r   r"   >   ó   zCacheManager.clearc                 O   ó   | j j|i |¤ŽS )zEvaluate a function)r   Úevalr#   r   r   r   r&   B   ó   zCacheManager.evalc                 O   r%   )z0Return the formatted representation of an object)r   Úformatr#   r   r   r   r(   F   r'   zCacheManager.formatc                 O   r!   )zReduce the size of the cacheN)r   Úreduce_sizer#   r   r   r   r)   J   r$   zCacheManager.reduce_sizec                 O   r!   )zRaise a warningN)r   Úwarnr#   r   r   r   r*   N   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   )Ú	mmap_modeÚcompressÚverboser   r   )r.   ÚosÚtypingr   r   r   Újoblibr   Ú	decoratorr   r   r   Úobjectr   ÚenvironÚgetr/   r   Ú__annotations__r   r   r   r   Ú<module>   s   	=û