AlkantarClanX12

Your IP : 18.191.97.229


Current Path : /opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/__pycache__/functools.cpython-34.pyo

�
j f_o�&@s�dZddddddddd	d
dgZydd
lmZWnek
rUYnXddlmZddlmZddl	m
Z
ddlmZyddl
mZWnGdd�d�ZYnXdQZdRZeedd�Zeedd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d�Zd6d�Z ydd7lm Z Wnek
r�YnXd8d	�Z!ydd9lm!Z!Wnek
r�YnXGd:d
�d
e"�Z#ed;d<d=d>d?g�Z$Gd@dA�dAe%�Z&e"�fe'e(e)e*dB�he+e,e*e-dCdD�Z.dEdFdGd�Z/dHdI�Z0dBdJdK�Z1dLdM�Z2dNdO�Z3dPd�Z4dBS)SzEfunctools.py - Tools for working with functions and callable objects
�update_wrapper�wraps�WRAPPER_ASSIGNMENTS�WRAPPER_UPDATES�total_ordering�
cmp_to_key�	lru_cache�reduce�partial�
partialmethod�singledispatch�)r)�get_cache_token)�
namedtuple)�MappingProxyType)�WeakKeyDictionary)�RLockc@s.eZdZdZdd�Zdd�ZdS)rz/Dummy reentrant lock for builds without threadscCsdS)N�)�selfrr�./opt/alt/python34/lib64/python3.4/functools.py�	__enter__szRLock.__enter__cCsdS)Nr)r�exctype�excinst�exctbrrr�__exit__szRLock.__exit__N)�__name__�
__module__�__qualname__�__doc__rrrrrrrsrrrrr�__annotations__�__dict__c
Cs�xF|D]>}yt||�}Wntk
r4YqXt|||�qWx0|D](}t||�jt||i��qPW||_|S)aUpdate a wrapper function to look like the wrapped function

       wrapper is the function to be updated
       wrapped is the original function
       assigned is a tuple naming the attributes assigned directly
       from the wrapped function to the wrapper function (defaults to
       functools.WRAPPER_ASSIGNMENTS)
       updated is a tuple naming the attributes of the wrapper that
       are updated with the corresponding attribute from the wrapped
       function (defaults to functools.WRAPPER_UPDATES)
    )�getattr�AttributeError�setattr�update�__wrapped__)�wrapper�wrapped�assigned�updated�attr�valuerrrr+s


&	cCsttd|d|d|�S)a�Decorator factory to apply update_wrapper() to a wrapper function

       Returns a decorator that invokes update_wrapper() with the decorated
       function as the wrapper argument and the arguments to wraps() as the
       remaining arguments. Default arguments are as for update_wrapper().
       This is a convenience function to simplify applying partial() to
       update_wrapper().
    r&r'r()r	r)r&r'r(rrrrIscCs0|j|�}|tkrtS|o/||kS)zIReturn a > b.  Computed by @total_ordering from (not a < b) and (a != b).)�__lt__�NotImplemented)r�other�	op_resultrrr�_gt_from_ltasr/cCs|j|�}|p||kS)zEReturn a <= b.  Computed by @total_ordering from (a < b) or (a == b).)r+)rr-r.rrr�_le_from_lthsr0cCs$|j|�}|tkrtS|S)z=Return a >= b.  Computed by @total_ordering from (not a < b).)r+r,)rr-r.rrr�_ge_from_ltmsr1cCs0|j|�}|tkrtS|p/||kS)zJReturn a >= b.  Computed by @total_ordering from (not a <= b) or (a == b).)�__le__r,)rr-r.rrr�_ge_from_letsr3cCs/|j|�}|tkrtS|o.||kS)zFReturn a < b.  Computed by @total_ordering from (a <= b) and (a != b).)r2r,)rr-r.rrr�_lt_from_le{sr4cCs$|j|�}|tkrtS|S)z=Return a > b.  Computed by @total_ordering from (not a <= b).)r2r,)rr-r.rrr�_gt_from_le�sr5cCs0|j|�}|tkrtS|o/||kS)zIReturn a < b.  Computed by @total_ordering from (not a > b) and (a != b).)�__gt__r,)rr-r.rrr�_lt_from_gt�sr7cCs|j|�}|p||kS)zEReturn a >= b.  Computed by @total_ordering from (a > b) or (a == b).)r6)rr-r.rrr�_ge_from_gt�sr8cCs$|j|�}|tkrtS|S)z=Return a <= b.  Computed by @total_ordering from (not a > b).)r6r,)rr-r.rrr�_le_from_gt�sr9cCs0|j|�}|tkrtS|p/||kS)zJReturn a <= b.  Computed by @total_ordering from (not a >= b) or (a == b).)�__ge__r,)rr-r.rrr�_le_from_ge�sr;cCs/|j|�}|tkrtS|o.||kS)zFReturn a > b.  Computed by @total_ordering from (a >= b) and (a != b).)r:r,)rr-r.rrr�_gt_from_ge�sr<cCs$|j|�}|tkrtS|S)z=Return a < b.  Computed by @total_ordering from (not a >= b).)r:r,)rr-r.rrr�_lt_from_ge�sr=csidtfdtfdtfgd6dtfdtfdtfgd6dtfdtfdtfgd6dt	fdt
fdtfgd6}�fdd�|D�}|s�td��nt
|�}x@||D]4\}}||kr�||_t�||�q�q�W�S)z6Class decorator that fills in missing ordering methodsr6r2r:r+cs:g|]0}t�|d�tt|d�k	r|�qS)N)r �object)�.0�op)�clsrr�
<listcomp>�s	z"total_ordering.<locals>.<listcomp>z6must define at least one ordering operation: < > <= >=)r/r0r1r3r4r5r7r8r9r;r<r=�
ValueError�maxrr")rA�convert�roots�root�opname�opfuncr)rArr�s,									cs G�fdd�dt�}|S)z,Convert a cmp= function into a key= functioncs�eZdZdgZdd�Z�fdd�Z�fdd�Z�fdd	�Z�fd
d�Z�fdd
�Z	�fdd�Z
dZdS)zcmp_to_key.<locals>.K�objcSs
||_dS)N)rJ)rrJrrr�__init__�szcmp_to_key.<locals>.K.__init__cs�|j|j�dkS)Nr)rJ)rr-)�mycmprrr+�szcmp_to_key.<locals>.K.__lt__cs�|j|j�dkS)Nr)rJ)rr-)rLrrr6�szcmp_to_key.<locals>.K.__gt__cs�|j|j�dkS)Nr)rJ)rr-)rLrr�__eq__�szcmp_to_key.<locals>.K.__eq__cs�|j|j�dkS)Nr)rJ)rr-)rLrrr2�szcmp_to_key.<locals>.K.__le__cs�|j|j�dkS)Nr)rJ)rr-)rLrrr:�szcmp_to_key.<locals>.K.__ge__cs�|j|j�dkS)Nr)rJ)rr-)rLrr�__ne__�szcmp_to_key.<locals>.K.__ne__N)rrr�	__slots__rKr+r6rMr2r:rN�__hash__r)rLrr�K�s	rQ)r>)rLrQr)rLrr�s)rcs7���fdd�}�|_�|_�|_|S)zSNew function with partial application of the given arguments
    and keywords.
    cs*�j�}|j|���||�S)N)�copyr#)ZfargsZ	fkeywordsZnewkeywords)�args�func�keywordsrr�newfunc�s
zpartial.<locals>.newfunc)rTrSrU)rTrSrUrVr)rSrTrUrr	�s
			)r	c@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zed
d��Z	dS)
r
z�Method descriptor with partial application of the given arguments
    and keywords.

    Supports wrapping existing descriptors and handles non-descriptor
    callables as instance methods.
    cOs�t|�r5t|d�r5tdj|���nt|t�r�|j|_|j||_|jj	�|_|jj
|�n||_||_||_dS)N�__get__z${!r} is not callable or a descriptor)�callable�hasattr�	TypeError�format�
isinstancer
rTrSrUrRr#)rrTrSrUrrrrKs			zpartialmethod.__init__cCs}djtt|j��}djdd�|jj�D��}d}|jd|jjd|jj	d|j
d|d	|�S)
Nz, css'|]\}}dj||�VqdS)z{}={!r}N)r[)r?�k�vrrr�	<genexpr>"sz)partialmethod.__repr__.<locals>.<genexpr>z*{module}.{cls}({func}, {args}, {keywords})�modulerArTrSrU)�join�map�reprrSrU�itemsr[�	__class__rrrT)rrSrU�
format_stringrrr�__repr__ s	zpartialmethod.__repr__cs+�fdd�}�j|_�|_|S)NcsR�jj�}|j|�|^}}|f�jt|�}�j||�S)N)rUrRr#rS�tuplerT)rSrU�
call_keywords�cls_or_self�rest�	call_args)rrr�_method,s

z3partialmethod._make_unbound_method.<locals>._method)�__isabstractmethod__�_partialmethod)rrmr)rr�_make_unbound_method+s	z"partialmethod._make_unbound_methodcCs�t|jdd�}d}|dk	r�|||�}||jk	r�t||j|j�}y|j|_Wq�tk
r�Yq�Xq�n|dkr�|j�j||�}n|S)NrW)	r rTr	rSrU�__self__r!rprW)rrJrA�get�result�new_funcrrrrW6s
zpartialmethod.__get__cCst|jdd�S)NrnF)r rT)rrrrrnIsz"partialmethod.__isabstractmethod__N)
rrrrrKrgrprW�propertyrnrrrrr
s�	CacheInfo�hits�misses�maxsize�currsizec@s7eZdZdZdZedd�Zdd�ZdS)�
_HashedSeqz� This class guarantees that hash() will be called no more than once
        per element.  This is important because the lru_cache() will hash
        the key multiple times on a cache miss.

    �	hashvaluecCs#||dd�<||�|_dS)N)r|)r�tup�hashrrrrK]sz_HashedSeq.__init__cCs|jS)N)r|)rrrrrPasz_HashedSeq.__hash__N)rrrrrOr~rKrPrrrrr{Tsr{Nc	s�|}	|rF||j��}
|	|7}	x|
D]}|	|7}	q/Wn|r�|	|�fdd�|D��7}	|r�|	|�fdd�|
D��7}	q�n0||	�dkr��|	d�|kr�|	dSt|	�S)a�Make a cache key from optionally typed positional and keyword arguments

    The key is constructed in a way that is flat as possible rather than
    as a nested structure that would take more memory.

    If there is only a single argument and its data type is known to cache
    its hash value, then that argument is returned without a wrapper.  This
    saves space and improves lookup speed.

    c3s|]}�|�VqdS)Nr)r?r^)�typerrr_ysz_make_key.<locals>.<genexpr>c3s!|]\}}�|�VqdS)Nr)r?r]r^)rrrr_{s�r)rdr{)rS�kwds�typed�kwd_mark�	fasttypes�sortedrhr�len�key�sorted_items�itemr)rr�	_make_keyds

#)(r��Fcsw�dk	r+t�t�r+td��nt��t�d	\������������fdd�}|S)
a�Least-recently-used cache decorator.

    If *maxsize* is set to None, the LRU features are disabled and the cache
    can grow without bound.

    If *typed* is True, arguments of different types will be cached separately.
    For example, f(3.0) and f(3) will be treated as distinct calls with
    distinct results.

    Arguments to the cached function must be hashable.

    View the cache statistics named tuple (hits, misses, maxsize, currsize)
    with f.cache_info().  Clear the cache and statistics with f.cache_clear().
    Access the underlying function with f.__wrapped__.

    See:  http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used

    Nz)Expected maxsize to be an integer or Nonerr���cs>i�d��d��j�t��g���ddg�dd�<�
dkrn��fdd�}nr�
dkr���������fdd�}n<��	�
��������
����fdd�}����
�fdd�}������fd	d
�}||_||_t|��S)NrFcs�||�}�d7�|S)Nr�r)rSr�rs)rx�
user_functionrrr%�s
z7lru_cache.<locals>.decorating_function.<locals>.wrappercsb�||��}�|��}|�k	r;�d7�|S�||�}|�|<�d7�|S)Nr�r)rSr�r�rs)�cache�	cache_getrw�make_keyrx�sentinelr�r�rrr%�s


cs��	||�
�}����|�}|dk	r�|\}}}}||�<||�<��}||�<��<||�<�|�<�d7�|SWdQX�||�}���|�kr�n��r$�}	||	�<||	�<|	����}
��}d��<��<�|
=|	�|<nH��}|�||g}||�<��<�|<t���
k��d7�WdQX|S)Nr�)r�)rSr�r��link�	link_prev�	link_next�_keyrs�last�oldroot�oldkey�	oldresult)�KEY�NEXT�PREV�RESULTr�r��fullrw�lockr�ryrxrGr�r�rrr%�sB













c
s*��t���t���SWdQXdS)zReport cache statisticsN)�
_CacheInfor�r)r�rwr�ryrxrr�
cache_info�sz:lru_cache.<locals>.decorating_function.<locals>.cache_infocsG��;�j���ddg�dd�<d��d�WdQXdS)z$Clear the cache and cache statisticsNrF)�clearr)r�r�rwr�rxrGrr�cache_clears


z;lru_cache.<locals>.decorating_function.<locals>.cache_clear)rrrr�r�r)r�r%r�r�)r�r�r�r�r�ryr�r�)r�r�r�rwr�rxrGr�r�decorating_function�s"
		*<7!			z&lru_cache.<locals>.decorating_function)rr�r�r�)r\�intrZr>r�)ryr�r�r)r�r�r�r�r�ryr�r�rr�s	'lcCs�g}x�dd�|D�}|s&|SxJ|D]B}|d}x/|D]&}||dd�krDd}PqDqDWPq-W|dkr�td��n|j|�x(|D] }|d|kr�|d=q�q�Wq	WdS)z�Merges MROs in *sequences* to a single MRO using the C3 algorithm.

    Adapted from http://www.python.org/download/releases/2.3/mro/.

    cSsg|]}|r|�qSrr)r?�srrrrBs	z_c3_merge.<locals>.<listcomp>rr�NzInconsistent hierarchy)�RuntimeError�append)�	sequencesrs�s1�	candidate�s2�seqrrr�	_c3_merges$




r�c
s�xOtt|j��D]2\}�t�d�rt|j�|}PqqWd}�rdt��ng�t|jd|��}g}t|j|d��}xP�D]H�t|��r�t�fdd�|jD��r�|j��q�q�Wx|D]��j	��q�W�fdd�|D�}�fdd�|D�}�fd	d�|D�}	t
|gg|||	|g|g|g�S)
a�Computes the method resolution order using extended C3 linearization.

    If no *abcs* are given, the algorithm works exactly like the built-in C3
    linearization used for method resolution.

    If given, *abcs* is a list of abstract base classes that should be inserted
    into the resulting MRO. Unrelated ABCs are ignored and don't end up in the
    result. The algorithm inserts ABCs where their functionality is introduced,
    i.e. issubclass(cls, abc) returns True for the class itself but returns
    False for all its direct base classes. Implicit ABCs for a given class
    (either registered or inferred from the presence of a special method like
    __len__) are inserted directly after the last ABC explicitly listed in the
    MRO of said class. If two implicit ABCs end up next to each other in the
    resulting MRO, their ordering depends on the order of types in *abcs*.

    �__abstractmethods__rNc3s|]}t|��VqdS)N)�
issubclass)r?�b)�baserrr_Osz_c3_mro.<locals>.<genexpr>cs"g|]}t|d���qS)�abcs)�_c3_mro)r?r�)r�rrrBVs	z_c3_mro.<locals>.<listcomp>cs"g|]}t|d���qS)r�)r�)r?r�)r�rrrBWs	cs"g|]}t|d���qS)r�)r�)r?r�)r�rrrBXs	)�	enumerate�reversed�	__bases__rYr��listr��anyr��remover�)
rAr��i�boundary�explicit_bases�abstract_bases�other_bases�explicit_c3_mros�abstract_c3_mros�
other_c3_mrosr)r�r�rr�2s("
 
r�csft�j����fdd���fdd��D���fdd���fdd��D��t���g}x��D]�}g}xU|j�D]G}|�kr�t�|�r�|j�fdd�|jD��q�q�W|s�|j|�q�n|jd	td
d�x;|D]3}x*|D]"}||kr(|j|�q(q(WqWq�Wt�d|�S)
z�Calculates the method resolution order for a given class *cls*.

    Includes relevant abstract base classes (with their respective bases) from
    the *types* iterable. Uses a modified C3 linearization algorithm.

    cs(|�ko't|d�o't�|�S)N�__mro__)rYr�)�typ)�basesrArr�
is_relatedhsz _compose_mro.<locals>.is_relatedcs"g|]}�|�r|�qSrr)r?�n)r�rrrBks	z _compose_mro.<locals>.<listcomp>cs4x-�D]%}||kr||jkrdSqWdS)NTF)r�)r�r-)�typesrr�is_strict_basens
z$_compose_mro.<locals>.is_strict_basecs"g|]}�|�s|�qSrr)r?r�)r�rrrBss	cs"g|]}|�kr|�qSrr)r?r�)�type_setrrrB|s	r��reverseTr�)�setr��__subclasses__r�r��sortr�r�)rAr��mror��found�sub�subclsr)r�rAr�r�r�r�r�_compose_mro_s*
*


r�cCs�t||j��}d}x�|D]�}|dk	r�||kr�||jkr�||jkr�t||�r�tdj||���nPn||kr"|}q"q"W|j|�S)a^Returns the best matching implementation from *registry* for type *cls*.

    Where there is no registered implementation for a specific type, its method
    resolution order is used to find a more generic implementation.

    Note: if *registry* does not contain an implementation for the base
    *object* type, this function may return None.

    NzAmbiguous dispatch: {} or {})r��keysr�r�r�r[rr)rA�registryr��match�trrr�
_find_impl�s

	
r�cs�i�t��d����fdd��d����fdd���fdd�}|�t<�|_�|_t��|_�j|_t||�|S)alSingle-dispatch generic function decorator.

    Transforms a function into a generic function, which can have different
    behaviours depending upon the type of its first argument. The decorated
    function acts as the default implementation, and additional
    implementations can be registered using the register() attribute of the
    generic function.

    Ncs��dk	r7t�}�|kr7�j�|�q7ny�|}WnNtk
r�y�|}Wn!tk
r�t|��}YnX|�|<YnX|S)z�generic_func.dispatch(cls) -> <function implementation>

        Runs the dispatch algorithm to return the best available implementation
        for the given *cls* registered on *generic_func*.

        N)r
r��KeyErrorr�)rA�
current_token�impl)�cache_token�dispatch_cacher�rr�dispatch�s	


z singledispatch.<locals>.dispatchcs^|dkr��fdd�S|��<�dkrPt�d�rPt��n�j�|S)z�generic_func.register(cls, func) -> func

        Registers a new implementation for the given *cls* on a *generic_func*.

        Ncs
��|�S)Nr)�f)rA�registerrr�<lambda>�sz2singledispatch.<locals>.register.<locals>.<lambda>r�)rYr
r�)rArT)r�r�r�r�)rArr��s

z singledispatch.<locals>.registercs�|dj�||�S)Nr)re)rS�kw)r�rrr%�szsingledispatch.<locals>.wrapper)	rr>r�r�rr�r��_clear_cacher)rTr%r)r�r�r�r�r�rr�s
	
		
)z
__module__z__name__z__qualname__z__doc__z__annotations__)z__dict__)5r�__all__�
_functoolsr�ImportError�abcr
�collectionsrr�r�weakrefr�_threadrrrrrr/r0r1r3r4r5r7r8r9r;r<r=rrr	r>r
r�r�r{r��str�	frozensetrr�rhr�r�rr�r�r�r�rrrrr�<module>sr


 


N	�-)