HEX
Server: LiteSpeed
System: Linux srv146.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: kodi1989 (1633)
PHP: 8.1.34
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/cachetools/__pycache__/__init__.cpython-37.pyc
B

��fb�@s$dZdZdZddlZddlZddlZddlZddlZddlZddl	m
Z
Gdd�d�ZGd	d
�d
ejj
�ZGdd�de�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Ze�dddddg�Ze
jdd fd!d"�Ze
jdfd#d$�ZdS)%z0Extensible memoizing collections and decorators.)
�Cache�	FIFOCache�LFUCache�LRUCache�MRUCache�RRCache�	TLRUCache�TTLCache�cached�cachedmethodz5.4.0�N�)�keysc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_DefaultSize�cCsdS)Nrr)�self�_rr�D/opt/alt/python37/lib/python3.7/site-packages/cachetools/__init__.py�__getitem__ sz_DefaultSize.__getitem__cCs|dkst�dS)Nr)�AssertionError)rr�valuerrr�__setitem__#sz_DefaultSize.__setitem__cCsdS)Nrr)rrrrr�pop&sz_DefaultSize.popN)�__name__�
__module__�__qualname__�	__slots__rrrrrrrrsrc@s�eZdZdZe�Ze�Zd!dd�Zdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zd"dd�Zefdd�Zd#dd�Zedd��Zedd��Zedd ��ZdS)$rz?Mutable mapping to serve as a simple cache or cache base class.NcCs6|r
||_|jtjk	rt�|_t�|_d|_||_dS)Nr)�	getsizeofr�dict�_Cache__size�_Cache__data�_Cache__currsize�_Cache__maxsize)r�maxsizerrrr�__init__1szCache.__init__cCsd|jjt|j�|j|jfS)Nz%s(%s, maxsize=%r, currsize=%r))�	__class__r�reprrr!r )rrrr�__repr__:s
zCache.__repr__cCs*y
|j|Stk
r$|�|�SXdS)N)r�KeyError�__missing__)r�keyrrrrBs
zCache.__getitem__cCs�|j}|�|�}||kr td��||jks8|j||krTx|j||krR|��q:W||jkrn||j|}n|}||j|<||j|<|j|7_dS)Nzvalue too large)r!r�
ValueErrorrrr �popitem)rr)rr"�sizeZdiffsizerrrrHs



zCache.__setitem__cCs&|j�|�}|j|=|j|8_dS)N)rrrr )rr)r,rrr�__delitem__XszCache.__delitem__cCs
||jkS)N)r)rr)rrr�__contains__]szCache.__contains__cCst|��dS)N)r')rr)rrrr(`szCache.__missing__cCs
t|j�S)N)�iterr)rrrr�__iter__cszCache.__iter__cCs
t|j�S)N)�lenr)rrrr�__len__fsz
Cache.__len__cCs||kr||S|SdS)Nr)rr)�defaultrrr�getisz	Cache.getcCs4||kr||}||=n||jkr,t|��n|}|S)N)�_Cache__markerr')rr)r3rrrrros

z	Cache.popcCs"||kr||}n|||<}|S)Nr)rr)r3rrrr�
setdefaultys
zCache.setdefaultcCs|jS)zThe maximum size of the cache.)r!)rrrrr"�sz
Cache.maxsizecCs|jS)zThe current size of the cache.)r )rrrr�currsize�szCache.currsizecCsdS)z+Return the size of a cache element's value.rr)rrrrr�szCache.getsizeof)N)N)N)rrr�__doc__�objectr5rrr#r&rrr-r.r(r0r2r4rr6�propertyr"r7�staticmethodrrrrrr*s$
	


rc@s>eZdZdZddd�Zejfdd�Zejfdd�Zd	d
�ZdS)rz/First In First Out (FIFO) cache implementation.NcCst�|||�t��|_dS)N)rr#�collections�OrderedDict�_FIFOCache__order)rr"rrrrr#�szFIFOCache.__init__cCs@||||�y|j�|�Wntk
r:d|j|<YnXdS)N)r>�move_to_endr')rr)r�
cache_setitemrrrr�s
zFIFOCache.__setitem__cCs|||�|j|=dS)N)r>)rr)�
cache_delitemrrrr-�s
zFIFOCache.__delitem__cCsNytt|j��}Wn(tk
r:tdt|�j�d�YnX||�|�fSdS)z9Remove and return the `(key, value)` pair first inserted.z%s is emptyN)�nextr/r>�
StopIterationr'�typerr)rr)rrrr+�s
zFIFOCache.popitem)N)	rrrr8r#rrr-r+rrrrr�s

rc@sLeZdZdZd
dd�Zejfdd�Zejfdd�Zejfd	d
�Zdd�Z	dS)rz1Least Frequently Used (LFU) cache implementation.NcCst�|||�t��|_dS)N)rr#r<�Counter�_LFUCache__counter)rr"rrrrr#�szLFUCache.__init__cCs(|||�}||kr$|j|d8<|S)Nr)rF)rr)�
cache_getitemrrrrr�s
zLFUCache.__getitem__cCs"||||�|j|d8<dS)Nr)rF)rr)rr@rrrr�szLFUCache.__setitem__cCs|||�|j|=dS)N)rF)rr)rArrrr-�s
zLFUCache.__delitem__cCsRy|j�d�\\}}Wn(tk
r>tdt|�j�d�YnX||�|�fSdS)z@Remove and return the `(key, value)` pair least frequently used.rz%s is emptyN)rF�most_commonr*r'rDrr)rr)rrrrr+�s
zLFUCache.popitem)N)
rrrr8r#rrrr-r+rrrrr�s
rc@sTeZdZdZddd�Zejfdd�Zejfdd�Zejfd	d
�Zdd�Z	d
d�Z
dS)rz/Least Recently Used (LRU) cache implementation.NcCst�|||�t��|_dS)N)rr#r<r=�_LRUCache__order)rr"rrrrr#�szLRUCache.__init__cCs |||�}||kr|�|�|S)N)�_LRUCache__update)rr)rGrrrrr�s

zLRUCache.__getitem__cCs||||�|�|�dS)N)rJ)rr)rr@rrrr�szLRUCache.__setitem__cCs|||�|j|=dS)N)rI)rr)rArrrr-�s
zLRUCache.__delitem__cCsNytt|j��}Wn(tk
r:tdt|�j�d�YnX||�|�fSdS)z>Remove and return the `(key, value)` pair least recently used.z%s is emptyN)rBr/rIrCr'rDrr)rr)rrrr+�s
zLRUCache.popitemcCs4y|j�|�Wntk
r.d|j|<YnXdS)N)rIr?r')rr)rrr�__update�szLRUCache.__update)N)rrrr8r#rrrr-r+rJrrrrr�s
	rc@sTeZdZdZddd�Zejfdd�Zejfdd�Zejfd	d
�Zdd�Z	d
d�Z
dS)rz.Most Recently Used (MRU) cache implementation.NcCs6ddlm}|dtdd�t�|||�t��|_dS)Nr)�warnzMRUCache is deprecated�)�
stacklevel)�warningsrL�DeprecationWarningrr#r<r=�_MRUCache__order)rr"rrLrrrr#�szMRUCache.__init__cCs |||�}||kr|�|�|S)N)�_MRUCache__update)rr)rGrrrrr�s

zMRUCache.__getitem__cCs||||�|�|�dS)N)rR)rr)rr@rrrrszMRUCache.__setitem__cCs|||�|j|=dS)N)rQ)rr)rArrrr-s
zMRUCache.__delitem__cCsNytt|j��}Wn(tk
r:tdt|�j�d�YnX||�|�fSdS)z=Remove and return the `(key, value)` pair most recently used.z%s is emptyN)rBr/rQrCr'rDrr)rr)rrrr+	s
zMRUCache.popitemcCs8y|jj|dd�Wntk
r2d|j|<YnXdS)NF)�last)rQr?r')rr)rrrrKszMRUCache.__update)N)rrrr8r#rrrr-r+rRrrrrr�s
	rc@s4eZdZdZejdfdd�Zedd��Zdd�ZdS)	rz-Random Replacement (RR) cache implementation.NcCst�|||�||_dS)N)rr#�_RRCache__choice)rr"�choicerrrrr#szRRCache.__init__cCs|jS)z(The `choice` function used by the cache.)rT)rrrrrU szRRCache.choicecCsNy|�t|��}Wn(tk
r:tdt|�j�d�YnX||�|�fSdS)z/Remove and return a random `(key, value)` pair.z%s is emptyN)rT�list�
IndexErrorr'rDrr)rr)rrrr+%s
zRRCache.popitem)	rrrr8�randomrUr#r:r+rrrrrsrcs�eZdZdZGdd�d�Zejdfdd�Zej	fdd�Z	ej
fd	d
�Z
e�fdd��Zed
d��Z
dd�Zdd�Zdd�Zdd�Z�ZS)�_TimedCachez0Base class for time aware cache implementations.c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)z_TimedCache._TimercCs||_d|_dS)Nr)�
_Timer__timer�_Timer__nesting)r�timerrrrr#3sz_TimedCache._Timer.__init__cCs|jdkr|��S|jSdS)Nr)r[rZ�_Timer__time)rrrr�__call__7s
z_TimedCache._Timer.__call__cCs2|jdkr|��|_}n|j}|jd7_|S)Nrr)r[rZr])r�timerrr�	__enter__=s

z_TimedCache._Timer.__enter__cGs|jd8_dS)Nr)r[)r�excrrr�__exit__Esz_TimedCache._Timer.__exit__cCstj|jffS)N)rY�_TimerrZ)rrrr�
__reduce__Hsz_TimedCache._Timer.__reduce__cCst|j|�S)N)�getattrrZ)r�namerrr�__getattr__Ksz_TimedCache._Timer.__getattr__N)	rrrr#r^r`rbrdrgrrrrrc2srcNcCst�|||�t�|�|_dS)N)rr#rYrc�_TimedCache__timer)rr"r\rrrrr#Nsz_TimedCache.__init__c	Cs$|j�}|�|�||�SQRXdS)N)rh�expire)rZ
cache_reprr_rrrr&Rs
z_TimedCache.__repr__c	Cs$|j�}|�|�||�SQRXdS)N)rhri)r�	cache_lenr_rrrr2Ws
z_TimedCache.__len__c	s$|j�}|�|�t�jSQRXdS)N)rhri�superr7)rr_)r$rrr7\s
z_TimedCache.currsizecCs|jS)z%The timer function used by the cache.)rh)rrrrr\bsz_TimedCache.timerc	Cs*|j�}|�|�t�|�WdQRXdS)N)rhrir�clear)rr_rrrrlgs
z_TimedCache.clearc	Os$|j�tj|f|�|�SQRXdS)N)rhrr4)r�args�kwargsrrrr4lsz_TimedCache.getc	Os$|j�tj|f|�|�SQRXdS)N)rhrr)rrmrnrrrrpsz_TimedCache.popc	Os$|j�tj|f|�|�SQRXdS)N)rhrr6)rrmrnrrrr6tsz_TimedCache.setdefault)rrrr8rcr_�	monotonicr#rr&r2r:r7r\rlr4rr6�
__classcell__rr)r$rrY/srYc@s�eZdZdZGdd�d�Zejdfdd�Zdd�Ze	j
fd	d
�Z
e	jfdd�Ze	jfd
d�Zdd�Z
dd�Zedd��Zddd�Zdd�Zdd�ZdS)rz@LRU Cache implementation with per-item time-to-live (TTL) value.c@s*eZdZdZd	dd�Zdd�Zdd�ZdS)
zTTLCache._Link)r)�expiresrB�prevNcCs||_||_dS)N)r)rq)rr)rqrrrr#�szTTLCache._Link.__init__cCstj|j|jffS)N)r�_Linkr)rq)rrrrrd�szTTLCache._Link.__reduce__cCs|j}|j}||_||_dS)N)rBrr)rrBrrrrr�unlink�szTTLCache._Link.unlink)NN)rrrrr#rdrtrrrrrs|s
rsNcCs>t�||||�t��|_}||_|_t��|_	||_
dS)N)rYr#rrs�_TTLCache__rootrrrBr<r=�_TTLCache__links�_TTLCache__ttl)rr"�ttlr\r�rootrrrr#�s

zTTLCache.__init__cCs6y|j|}Wntk
r"dSX|��|jkSdS)NF)rvr'r\rq)rr)�linkrrrr.�s
zTTLCache.__contains__cCsTy|�|�}Wntk
r&d}YnX|��|jk}|rF|�|�S|||�SdS)NF)�_TTLCache__getlinkr'r\rqr()rr)rGrz�expiredrrrr�s

zTTLCache.__getitem__c	Cs�|j�}|�|�||||�WdQRXy|�|�}Wn(tk
r^t�|�|j|<}Yn
X|��||j|_	|j
|_}|j|_}||_|_dS)N)
r\rir{r'rrsrvrtrwrqrurBrr)rr)rr@r_rzryrrrrrr�s
zTTLCache.__setitem__cCs8|||�|j�|�}|��|��|jks4t|��dS)N)rvrrtr\rqr')rr)rArzrrrr-�s

zTTLCache.__delitem__c	csH|j}|j}x6||k	rB|j�}||jkr0|jVWdQRX|j}qWdS)N)rurBr\rqr))rry�currr_rrrr0�s

zTTLCache.__iter__cCsn|j�|�|j}||_|_x<t|j��dd�d�D]"}||_|j|_}||_|_q6W|�|�	��dS)NcSs|jS)N)rq)�objrrr�<lambda>��z'TTLCache.__setstate__.<locals>.<lambda>)r))
�__dict__�updaterurrrB�sortedrv�valuesrir\)r�stateryrzrrrrr�__setstate__�szTTLCache.__setstate__cCs|jS)z,The time-to-live value of the cache's items.)rw)rrrrrx�szTTLCache.ttlcCsj|dkr|��}|j}|j}|j}tj}x<||k	rd||jksd|||j�||j=|j}|��|}q*WdS)z$Remove expired items from the cache.N)	r\rurBrvrr-rqr)rt)rr_ryr}�linksrArBrrrri�szTTLCache.expirec	Csj|j�Z}|�|�ytt|j��}Wn(tk
rLtdt|�j�d�YnX||�	|�fSWdQRXdS)zmRemove and return the `(key, value)` pair least recently used that
        has not already expired.

        z%s is emptyN)
r\rirBr/rvrCr'rDrr)rr_r)rrrr+�s
zTTLCache.popitemcCs|j|}|j�|�|S)N)rvr?)rr)rrrrZ	__getlink�s
zTTLCache.__getlink)N)rrrr8rsr_ror#r.rrrr-r0r�r:rxrir+r{rrrrrys


rc@s�eZdZdZejGdd�d��Zejdfdd�Z	dd�Z
ejfd	d
�Zej
fdd�Z
ejfd
d�Zdd�Zedd��Zddd�Zdd�Zdd�ZdS)rz;Time aware Least Recently Used (TLRU) cache implementation.c@s"eZdZdZddd�Zdd�ZdS)zTLRUCache._Item)r)rq�removedNcCs||_||_d|_dS)NF)r)rqr�)rr)rqrrrr#szTLRUCache._Item.__init__cCs|j|jkS)N)rq)r�otherrrr�__lt__szTLRUCache._Item.__lt__)NN)rrrrr#r�rrrr�_Item�s
r�NcCs*t�||||�t��|_g|_||_dS)N)rYr#r<r=�_TLRUCache__items�_TLRUCache__order�_TLRUCache__ttu)rr"�ttur\rrrrr#
s
zTLRUCache.__init__cCs6y|j|}Wntk
r"dSX|��|jkSdS)NF)r�r'r\rq)rr)�itemrrrr.s
zTLRUCache.__contains__cCsTy|�|�}Wntk
r&d}YnX|��|jk}|rF|�|�S|||�SdS)NF)�_TLRUCache__getitemr'r\rqr()rr)rGr�r|rrrrs

zTLRUCache.__getitem__c	Cs�|j�6}|�|||�}||ks"dS|�|�||||�WdQRXyd|�|�_Wntk
rfYnXt�||�|j|<}t	�
|j|�dS)NT)r\r�rir�r�r'rr�r��heapq�heappushr�)rr)rr@r_rqr�rrrr$s
zTLRUCache.__setitem__c	CsD|j�}|||�WdQRX|j�|�}d|_||jks@t|��dS)NT)r\r�rr�rqr')rr)rAr_r�rrrr-4s
zTLRUCache.__delitem__c
cs>x8|jD].}|j�}||jkr,|js,|jVWdQRXqWdS)N)r�r\rqr�r))rr}r_rrrr0=szTLRUCache.__iter__cCs|jS)z1The local time-to-use function used by the cache.)r�)rrrrr�Dsz
TLRUCache.ttucCs�|dkr|��}|j}|j}t|�t|�dkrNdd�|D�|_}t�|�tj}xD|r�|djsr||dj	ks�t�
|�}|jsV|||j�||j=qVWdS)z$Remove expired items from the cache.NrMcSsg|]}|js|�qSr)r�)�.0r�rrr�
<listcomp>Qsz$TLRUCache.expire.<locals>.<listcomp>r)r\r�r�r1r��heapifyrr-r�rq�heappopr))rr_�items�orderrAr�rrrriIs

zTLRUCache.expirec	Csh|j�X}|�|�ytt|j��}Wn&tk
rJtd|jj�d�YnX||�	|�fSWdQRXdS)zmRemove and return the `(key, value)` pair least recently used that
        has not already expired.

        z%s is emptyN)
r\rirBr/r�rCr'r$rr)rr_r)rrrr+Zs
zTLRUCache.popitemcCs|j|}|j�|�|S)N)r�r?)rr)rrrrZ	__getitemhs
zTLRUCache.__getitem)N)rrrr8�	functools�total_orderingr�r_ror#r.rrrr-r0r:r�rir+r�rrrrr�s
	
r�	CacheInfo�hits�missesr"r7Fcs����fdd�}|S)z_Decorator to wrap a function with a memoizing callable that saves
    results in a cache.

    cs��r�d��t�t�r(���fdd��n.t�tjj�rH���fdd��n��fdd���dkr���fdd�}��fdd	�}�}nh�dkr������fd
d�}���fdd	�}�}n6������fdd�}����fd
d	�}��fdd�}nl�dk�r
�fdd�}dd	�}nH�dk�r2���fdd�}�fdd	�}n ����fdd�}��fdd	�}d}�|_�|_�|_||_||_	t
�|��S)Nrcst���j�j�S)N)�
_CacheInfor"r7r)�cacher�r�rr�getinfosz*cached.<locals>.decorator.<locals>.getinfocst��dt���S)N)r�r1r)r�r�r�rrr��scst��dd�S)Nr)r�r)r�r�rrr��scs�d7��||�S)Nrr)rmrn)�funcr�rr�wrapper�sz*cached.<locals>.decorator.<locals>.wrappercsd��dS)Nrrr)r�r�rr�cache_clear�sz.cached.<locals>.decorator.<locals>.cache_clearcsl�||�}y�|}�d7�|Stk
r:�d7�YnX�||�}y|�|<Wntk
rfYnX|S)Nr)r'r*)rmrn�k�result�v)r�r�r�r)r�rrr��s

cs���d��dS)Nr)rlr)r�r�r�rrr��scs��||�}y$���|}�d7�|SQRXWn,tk
rZ���d7�WdQRXYnX�||�}y����||�SQRXWntk
r�|SXdS)Nr)r'r6r*)rmrnr�r�r�)r�r�r�r)�lockr�rrr��s

c	s$�����d��WdQRXdS)Nr)rlr)r�r�r�r�rrr��sc	s����SQRXdS)Nrr)r�r�rr�
cache_info�sz-cached.<locals>.decorator.<locals>.cache_infocs
�||�S)Nr)rmrn)r�rrr��scSsdS)Nrrrrrr��scsX�||�}y�|Stk
r&YnX�||�}y|�|<Wntk
rRYnX|S)N)r'r*)rmrnr�r�)r�r�r)rrr��s

cs���dS)N)rlr)r�rrr��sc	sx�||�}y��
�|SQRXWntk
r6YnX�||�}y����||�SQRXWntk
rr|SXdS)N)r'r6r*)rmrnr�r�)r�r�r)r�rrr��s

c	s�����WdQRXdS)N)rlr)r�r�rrr�s)�
isinstancerr<�abc�Mappingr��	cache_key�
cache_lockr�r�r��update_wrapper)r�r�r�r�)r��infor)r�)r�r�r�r�r�	decoratorysB




zcached.<locals>.decoratorr)r�r)r�r�r�r)r�r�r)r�rr	ssr	cs���fdd�}|S)zoDecorator to wrap a class or instance method with a memoizing
    callable that saves results in a cache.

    csj�dkr&���fdd�}�fdd�}n ����fdd�}��fdd�}�|_�|_�|_||_t�|��S)Ncs��|�}|dkr �|f|�|�S�|f|�|�}y||Stk
rLYnX�|f|�|�}y|||<Wntk
r~YnX|S)N)r'r*)rrmrn�cr�r�)r�r)�methodrrr�sz0cachedmethod.<locals>.decorator.<locals>.wrappercs�|�}|dk	r|��dS)N)rl)rr�)r�rrrl*sz.cachedmethod.<locals>.decorator.<locals>.clearc	s��|�}|dkr �|f|�|�S�|f|�|�}y�|��
||SQRXWntk
r`YnX�|f|�|�}y �|��|�||�SQRXWntk
r�|SXdS)N)r'r6r*)rrmrnr�r�r�)r�r)r�r�rrr�1s

c	s0�|�}|dk	r,�|��|��WdQRXdS)N)rl)rr�)r�r�rrrlCs
)r�r�r�r�r�r�)r�r�rl)r�r)r�)r�rr�szcachedmethod.<locals>.decoratorr)r�r)r�r�r)r�r)r�rr
s9r
)r8�__all__�__version__r<�collections.abcr�r�rXr_�r
rr��MutableMappingrrrrrrrYrr�
namedtupler�Zhashkeyr	Z	methodkeyr
rrrr�<module>s2f%)Jt