ž ­ÿf5c@smdZddddddddd g Zd d lmZmZd d lmZyd d lmZWnGdd„dƒZYnXd'Z d(Z e e dd„Z e e dd„Z dd„Z dd„Zyd dlmZWnek rïYnXedddddgƒZGd d!„d!eƒZeƒfeeeed&ƒheeeed"d#„Zd$d)d%d„Zd&S(*uEfunctools.py - Tools for working with functions and callable objects uupdate_wrapperuwrapsuWRAPPER_ASSIGNMENTSuWRAPPER_UPDATESutotal_orderingu cmp_to_keyu lru_cacheureduceupartiali(upartialureduce(u namedtuple(uRLockcBs2|EeZdZdZdd„Zdd„ZdS(uRLocku/Dummy reentrant lock for builds without threadscCsdS(N((uself((u./opt/alt/python33/lib64/python3.3/functools.pyu __enter__suRLock.__enter__cCsdS(N((uselfuexctypeuexcinstuexctb((u./opt/alt/python33/lib64/python3.3/functools.pyu__exit__suRLock.__exit__N(u__name__u __module__u __qualname__u__doc__u __enter__u__exit__(u __locals__((u./opt/alt/python33/lib64/python3.3/functools.pyuRLocks uRLocku __module__u__name__u __qualname__u__doc__u__annotations__u__dict__c Cs‰||_xF|D]>}yt||ƒ}Wntk r=YqXt|||ƒqWx0|D](}t||ƒjt||iƒƒqYW|S(uUpdate 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) (u __wrapped__ugetattruAttributeErrorusetattruupdate(uwrapperuwrappeduassigneduupdateduattruvalue((u./opt/alt/python33/lib64/python3.3/functools.pyuupdate_wrapper#s    &cCsttd|d|d|ƒS(u‹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(). uwrappeduassigneduupdated(upartialuupdate_wrapper(uwrappeduassigneduupdated((u./opt/alt/python33/lib64/python3.3/functools.pyuwraps?s csliddd„fddd„fddd„fgd6dd d„fdd d„fdd d„fgd6dd d„fdd d„fddd„fgd6ddd„fddd„fddd„fgd6}‡fdd†|Dƒ}|stdƒ‚nt|ƒ}xU||D]I\}}||kr||_tt|ƒj|_tˆ||ƒqqWˆS(u6Class decorator that fills in missing ordering methodsu__gt__cSs||kp||k S(N((uselfuother((u./opt/alt/python33/lib64/python3.3/functools.pyuUsu total_ordering..u__le__cSs||kp||kS(N((uselfuother((u./opt/alt/python33/lib64/python3.3/functools.pyuVsu__ge__cSs ||k S(N((uselfuother((u./opt/alt/python33/lib64/python3.3/functools.pyuWsu__lt__cSs||k p||kS(N((uselfuother((u./opt/alt/python33/lib64/python3.3/functools.pyuXscSs||ko||k S(N((uselfuother((u./opt/alt/python33/lib64/python3.3/functools.pyuYscSs ||k S(N((uselfuother((u./opt/alt/python33/lib64/python3.3/functools.pyuZscSs||kp||k S(N((uselfuother((u./opt/alt/python33/lib64/python3.3/functools.pyu[scSs||kp||kS(N((uselfuother((u./opt/alt/python33/lib64/python3.3/functools.pyu\scSs ||k S(N((uselfuother((u./opt/alt/python33/lib64/python3.3/functools.pyu]scSs||k p||kS(N((uselfuother((u./opt/alt/python33/lib64/python3.3/functools.pyu^scSs||ko||k S(N((uselfuother((u./opt/alt/python33/lib64/python3.3/functools.pyu_scSs ||k S(N((uselfuother((u./opt/alt/python33/lib64/python3.3/functools.pyu`scs:g|]0}tˆ|dƒtt|dƒk r|‘qS(N(ugetattruNoneuobject(u.0uop(ucls(u./opt/alt/python33/lib64/python3.3/functools.pyu cs u"total_ordering..u6must define at least one ordering operation: < > <= >=(u ValueErrorumaxu__name__ugetattruintu__doc__usetattr(uclsuconverturootsurootuopnameuopfunc((uclsu./opt/alt/python33/lib64/python3.3/functools.pyutotal_orderingRs.   cs G‡fdd†dtƒ}|S(u,Convert a cmp= function into a key= functioncs›|EeZdZdgZdd„Z‡fdd†Z‡fdd†Z‡fdd †Z‡fd d †Z‡fd d †Z ‡fdd†Z dZ dS(ucmp_to_key..KuobjcSs ||_dS(N(uobj(uselfuobj((u./opt/alt/python33/lib64/python3.3/functools.pyu__init__wsucmp_to_key..K.__init__csˆ|j|jƒdkS(Ni(uobj(uselfuother(umycmp(u./opt/alt/python33/lib64/python3.3/functools.pyu__lt__ysucmp_to_key..K.__lt__csˆ|j|jƒdkS(Ni(uobj(uselfuother(umycmp(u./opt/alt/python33/lib64/python3.3/functools.pyu__gt__{sucmp_to_key..K.__gt__csˆ|j|jƒdkS(Ni(uobj(uselfuother(umycmp(u./opt/alt/python33/lib64/python3.3/functools.pyu__eq__}sucmp_to_key..K.__eq__csˆ|j|jƒdkS(Ni(uobj(uselfuother(umycmp(u./opt/alt/python33/lib64/python3.3/functools.pyu__le__sucmp_to_key..K.__le__csˆ|j|jƒdkS(Ni(uobj(uselfuother(umycmp(u./opt/alt/python33/lib64/python3.3/functools.pyu__ge__sucmp_to_key..K.__ge__csˆ|j|jƒdkS(Ni(uobj(uselfuother(umycmp(u./opt/alt/python33/lib64/python3.3/functools.pyu__ne__ƒsucmp_to_key..K.__ne__N( u__name__u __module__u __qualname__u __slots__u__init__u__lt__u__gt__u__eq__u__le__u__ge__u__ne__uNoneu__hash__(u __locals__(umycmp(u./opt/alt/python33/lib64/python3.3/functools.pyuKus  uK(uobject(umycmpuK((umycmpu./opt/alt/python33/lib64/python3.3/functools.pyu cmp_to_keyss(u cmp_to_keyu CacheInfouhitsumissesumaxsizeucurrsizecBs;|EeZdZdZdZedd„Zdd„ZdS(u _HashedSequà 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. u hashvaluecCs#||dd…<||ƒ|_dS(N(u hashvalue(uselfutupuhash((u./opt/alt/python33/lib64/python3.3/functools.pyu__init__su_HashedSeq.__init__cCs|jS(N(u hashvalue(uself((u./opt/alt/python33/lib64/python3.3/functools.pyu__hash__¡su_HashedSeq.__hash__N(u__name__u __module__u __qualname__u__doc__u __slots__uhashu__init__u__hash__(u __locals__((u./opt/alt/python33/lib64/python3.3/functools.pyu _HashedSeq”su _HashedSeqc sØ|} |rF||jƒƒ} | |7} x| D]} | | 7} q/Wn|rž| |‡fdd†|Dƒƒ7} |rÎ| |‡fdd†| Dƒƒ7} qÎn0|| ƒdkrΈ| dƒ|krÎ| dSt| ƒS(u‘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(N((u.0uv(utype(u./opt/alt/python33/lib64/python3.3/functools.pyu ¹su_make_key..c3s!|]\}}ˆ|ƒVqdS(N((u.0ukuv(utype(u./opt/alt/python33/lib64/python3.3/functools.pyu »sii(uitemsu _HashedSeq( uargsukwdsutypedukwd_marku fasttypesusortedutupleutypeulenukeyu sorted_itemsuitem((utypeu./opt/alt/python33/lib64/python3.3/functools.pyu _make_key¤s  #)(u _make_keyi€csLtƒ‰t‰d\‰‰‰‰‡‡‡‡‡‡‡‡fdd†}|S(u›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 iiiics>i‰d‰‰d ‰ˆj‰tƒ‰g‰ˆˆddgˆdd…<ˆ dkrn‡‡fdd†}nrˆ dkr¤‡‡‡‡ ‡‡‡‡fdd†}n<‡‡ ‡ ‡ ‡‡‡‡‡‡ ‡ ‡‡‡‡fdd†}‡‡‡‡ ‡fdd†}‡‡‡‡‡‡fdd †}||_||_t|ˆƒS( Nicsˆ||Ž}ˆd7‰|S(Ni((uargsukwdsuresult(umissesu user_function(u./opt/alt/python33/lib64/python3.3/functools.pyuwrapperês u7lru_cache..decorating_function..wrappercsbˆ||ˆƒ}ˆ|ˆƒ}|ˆk r;ˆd7‰|Sˆ||Ž}|ˆ|<ˆd7‰|S(Ni((uargsukwdsukeyuresult(ucacheu cache_getuhitsumake_keyumissesusentinelutypedu user_function(u./opt/alt/python33/lib64/python3.3/functools.pyuwrapperós    c s€ˆ ||ˆ ƒ}ˆˆ|ƒ}|dk r•|\}}}}||ˆ<||ˆ<ˆ ˆ}||ˆ<ˆ ˆ<||ˆ<ˆ |ˆ<ˆd7‰|SWdQXˆ||Ž}ˆÊ|ˆkrÀn¬ˆr$ˆ } || ˆ<|| ˆ<| ˆ‰ ˆ ˆ} ˆ ˆ} dˆ ˆ<ˆ ˆ<ˆ| =| ˆ|.decorating_function..cache_infoc sGˆ;ˆjƒˆˆddgˆdd…s   u;lru_cache..decorating_function..cache_clearF(uFalseugetuRLockuNoneu cache_infou cache_clearuupdate_wrapper(u user_functionuwrapperu cache_infou cache_clear(uKEYuNEXTuPREVuRESULTumake_keyumaxsizeusentinelutyped(ucacheu cache_getufulluhitsulockumissesurootu user_functionu./opt/alt/python33/lib64/python3.3/functools.pyudecorating_functionÞs"     *<7!  u&lru_cache..decorating_function(iiii(uobjectu _make_key(umaxsizeutypedudecorating_function((uKEYuNEXTuPREVuRESULTumake_keyumaxsizeusentinelutypedu./opt/alt/python33/lib64/python3.3/functools.pyu lru_cacheÀs  'mN(u __module__u__name__u __qualname__u__doc__u__annotations__(u__dict__F(u__doc__u__all__u _functoolsupartialureduceu collectionsu namedtupleu_threaduRLockuWRAPPER_ASSIGNMENTSuWRAPPER_UPDATESuupdate_wrapperuwrapsutotal_orderingu cmp_to_keyu ImportErroru _CacheInfoulistu _HashedSequobjectuintustru frozensetutypeuNoneusortedutupleulenu _make_keyuFalseu lru_cache(((u./opt/alt/python33/lib64/python3.3/functools.pyus6   !