Yohohohohohooho | Sanrei Aya
Sanrei Aya


Server : LiteSpeed
System : Linux barito.iixcp.rumahweb.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : elvh3918 ( 1528)
PHP Version : 8.2.31
Disable Function : mail
Directory :  /usr/local/lib/python3.9/site-packages/kombu/utils/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/local/lib/python3.9/site-packages/kombu/utils/__pycache__/functional.cpython-39.pyc
a

��Sh�)�	@sJdZddlmZddlZddlZddlZddlmZmZddl	m
Z
mZddlm
Z
mZddlmZmZddlmZd	d
lmZdZe�ZGdd
�d
�ZGdd�de�Zddefdd�ZGdd�d�Zdd�Zeefe
ffdd�Zeeffdd�Z d2dd�Z!dd�Z"d3d d!�Z#d4d#d$�Z$d5d'd(�Z%d6d+d,�Z&d7d.d/�Z'd0d1�Z(eZ)eZ*dS)8zFunctional Utilities.�)�annotationsN)�OrderedDict�UserDict)�Iterable�Mapping)�count�repeat)�sleep�time)�wraps�)�	safe_repr)�LRUCache�memoize�lazy�maybe_evaluate�is_list�
maybe_list�
dictfilter�retry_over_timec@s$eZdZdd�Zdd�Zdd�ZdS)�ChannelPromisecCs
||_dS�N)�__contract__)�selfZcontract�r�@/usr/local/lib/python3.9/site-packages/kombu/utils/functional.py�__init__szChannelPromise.__init__cCs2z|jWSty,|��}|_|YS0dSr)�	__value__�AttributeErrorr)r�valuerrr�__call__s
zChannelPromise.__call__cCs8zt|j�WSty2dt|j�d�d�YS0dS)Nz<promise: 0x�x�>)�reprrr�idr�rrrr�__repr__%szChannelPromise.__repr__N)�__name__�
__module__�__qualname__rr r&rrrrrsrc@s�eZdZdZddd�Zdd�Zdd�Zdd
d�Zdd
�Zdd�Z	dd�Z
e
Zdd�ZeZ
dd�ZeZddd�Zdd�Zdd�ZeZeZe
ZdS) raMLRU Cache implementation using a doubly linked list to track access.

    Arguments:
    ---------
        limit (int): The maximum number of keys to keep in the cache.
            When a new key is inserted and the limit has been exceeded,
            the *Least Recently Used* key will be discarded from the
            cache.
    NcCs||_t��|_t�|_dSr)�limit�	threading�RLock�mutexr�data)rr*rrrr7s
zLRUCache.__init__cCsB|j�(|j�|�}||<|Wd�S1s40YdSr)r-r.�pop�r�keyrrrr�__getitem__<szLRUCache.__getitem__cOsz|j�`|j|j}}|j|i|��|rXt|�|krXtt|�|�D]}|jdd�qFWd�n1sl0YdS)NF)�last)r-r.r*�update�len�range�popitem)r�args�kwargsr.r*�_rrrr4AszLRUCache.updateTcCs6|j�|j�|�Wd�S1s(0YdSr)r-r.r7)rr3rrrr7JszLRUCache.popitemcCs`|j�F|jr4t|j�|jkr4|j�tt|j���||j|<Wd�n1sR0YdSr)r-r*r5r.r/�next�iterr0rrr�__setitem__NszLRUCache.__setitem__cCs
t|j�Sr)r<r.r%rrr�__iter__UszLRUCache.__iter__c
cs\|j�B|D],}z||j|fVWqty6Yq0qWd�n1sN0YdSr�r-r.�KeyError�r�krrr�_iterate_itemsXszLRUCache._iterate_itemsc
csX|j�>|D](}z|j|VWqty2Yq0qWd�n1sJ0YdSrr?rArrr�_iterate_valuesaszLRUCache._iterate_valuescCs4|j�|j��Wd�S1s&0YdSr)r-r.�keysr%rrr�
_iterate_keyskszLRUCache._iterate_keysrcCsN|j�4t|j�|��|}t|�||<|Wd�S1s@0YdSr)r-�intr.r/�str)rr1�deltaZnewvalrrr�incrqsz
LRUCache.incrcCstt|��}|�d�|S)Nr-)�dict�varsr/)r�drrr�__getstate__ys
zLRUCache.__getstate__cCs||_t��|_dSr)�__dict__r+r,r-)r�staterrr�__setstate__~szLRUCache.__setstate__)N)T)r)r'r(r)�__doc__rr2r4r7r=r>rC�	iteritemsrD�
itervaluesrF�iterkeysrJrNrQrE�values�itemsrrrrr,s&

	

rcs���fdd�}|S)z)Decorator to cache function return value.csXt�����d��t�������fdd�����fdd�}d�_�_|�_��_�S)N)r*cs��r�||�}n|tftt|����}z0���|}Wd�n1sN0YWnZty��|i|��}�jd7_��|�|<Wd�n1s�0YYn0�jd7_|S)Nr)�KEYWORD_MARK�tuple�sortedrWr@�misses�hits)r8r9r1r)�_M�cache�fun�keyfunr-rrr]�s*,z%memoize.<locals>._memoize.<locals>._Mcs���d�_�_dS)z+Clear the cache and reset cache statistics.rN)�clearr\r[r)r]r^rrra�sz(memoize.<locals>._memoize.<locals>.clearr)r+�Lockrr\r[raZ
original_func)r_ra��Cacher`�maxsize)r]r^r_r-r�_memoize�s
zmemoize.<locals>._memoizer)rer`rdrfrrcrr�s rc@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)ra
Holds lazy evaluation.

    Evaluated when called or if the :meth:`evaluate` method is called.
    The function is re-evaluated on every call.

    Overloaded operations that will evaluate the promise:
        :meth:`__str__`, :meth:`__repr__`, :meth:`__cmp__`.
    cOs||_||_||_dSr��_fun�_args�_kwargs)rr_r8r9rrrr�sz
lazy.__init__cCs|��Sr)�evaluater%rrrr �sz
lazy.__call__cCs|j|ji|j��Srrgr%rrrrk�sz
lazy.evaluatecCs
t|��Sr)rHr%rrr�__str__�szlazy.__str__cCs
t|��Sr)r#r%rrrr&�sz
lazy.__repr__cCs
|�|kSrr�r�rhsrrr�__eq__�szlazy.__eq__cCs
|�|kSrrrmrrr�__ne__�szlazy.__ne__cCs||t|�<|Sr)r$)r�memorrr�__deepcopy__�szlazy.__deepcopy__cCs|j|jf|j|jd�fS)N)rirj)�	__class__rhrirjr%rrr�
__reduce__�s�zlazy.__reduce__N)
r'r(r)rRrr rkrlr&rorprrrtrrrrr�s	rcCst|t�r|��S|S)z9Evaluate value only if value is a :class:`lazy` instance.)�
isinstancerrk)rrrrr�s
rcCst||�ot||pd�S)zwReturn true if the object is iterable.

    Note:
    ----
        Returns false if object is a mapping or string.
    r)ru)�obj�scalarsZitersrrrr�srcCs|dust||�r|S|gS)z0Return list of one element if ``l`` is a scalar.N)r)rvrwrrrr�srcKs6|dur|n|r t|fi|��n|}dd�|��D�S)z=Remove all keys from dict ``d`` whose value is :const:`None`.NcSsi|]\}}|dur||�qSrr��.0rB�vrrr�
<dictcomp>��zdictfilter.<locals>.<dictcomp>)rKrW)rM�kwrrrr�s$rccs2t|�}tj}td�D]}||�|dVqdS)Nr)�list�random�shuffler)�itr�r:rrr�shufflecycle�s
r���?Fccs:|d}|r||kr$|V||7}q|s*q6||VqdS)Nr�r)�start�stop�step�
repeatlast�currrr�fxrange�s
r��Y@ccsHd|d}}||krqD|V|r2t|||�}n||7}||7}qdS)Nrr�)�min)r�r�r��maxZsum_r�rrr�
fxrangemaxsr���cCs|sin|}|sgn|}t||||dd�}|
r:t�|
nd}t�D]�}
z||i|��WS|�y}z�|dur�|
|kr��|r�t�|kr��|	r�|	�t|r�||||
�nt|��}|r�tt|��D]}|	r�|	�td�q�ttt|�|��WYd}~qDd}~00qDdS)aRetry the function over and over until max retries is exceeded.

    For each retry we sleep a for a while before we try again, this interval
    is increased for every retry until the max seconds is reached.

    Arguments:
    ---------
        fun (Callable): The function to try
        catch (Tuple[BaseException]): Exceptions to catch, can be either
            tuple or a single exception class.

    Keyword Arguments:
    -----------------
        args (Tuple): Positional arguments passed on to the function.
        kwargs (Dict): Keyword arguments passed on to the function.
        errback (Callable): Callback for when an exception in ``catch``
            is raised.  The callback must take three arguments:
            ``exc``, ``interval_range`` and ``retries``, where ``exc``
            is the exception instance, ``interval_range`` is an iterator
            which return the time in seconds to sleep next, and ``retries``
            is the number of previous retries.
        max_retries (int): Maximum number of retries before we give up.
            If neither of this and timeout is set, we will retry forever.
            If one of this and timeout is reached, stop.
        interval_start (float): How long (in seconds) we start sleeping
            between retries.
        interval_step (float): By how much the interval is increased for
            each retry.
        interval_max (float): Maximum number of seconds to sleep
            between retries.
        timeout (int): Maximum seconds waiting before we give up.
    T)r�Nr�)	r�r
r�floatr;r6rGr	�abs)r_Zcatchr8r9Zerrback�max_retriesZinterval_startZ
interval_stepZinterval_max�callback�timeoutZinterval_range�end�retries�excZttsr:rrrrs4#�
�
r�, �{0}={1}cs|��fdd�|��D��S)Nc3s"|]\}}��|t|��VqdSr)�format�
_safe_reprrx��fmtrr�	<genexpr>Rr|zreprkwargs.<locals>.<genexpr>)�joinrW)r9�sepr�rr�r�
reprkwargsQsr�rcCs>|sin|}d�||�tt|p d��|r0|r0|p2dt||��S)Nz
{}({}{}{})r�)r�r��mapr�r�)�namer8r9r�rrr�reprcallUs�r�cCst�|�}||jvp||jvSr)�inspect�getfullargspecr8�
kwonlyargs)�func�
argument_nameZ
argument_specrrr�accepts_argument^s

�r�)N)r�Nr�F)r�Nr�r�)	NNNNr�r�r�NN)r�r�)rNr�)+rR�
__future__rr�rr+�collectionsrr�collections.abcrr�	itertoolsrrr
r	Z
vine.utilsr�encodingr
r��__all__�objectrXrrrrrrHrrrr�r�r�rr�r�r�ZpromiseZ
maybe_promiserrrr�<module>s@[%*




�
>

		

Yohohohohohooho | Sanrei Aya