
    >                         S r / SQrSSKJrJr  SSKJrJr  SSKJ	r
  SSKJr  SSKr SS	KJr   " S
 S\5      r " S S\5      rSrSr\\4S jr\\4S jrS rS r\" SS5      rSS jr g! \ a	    SS	KJr   NKf = f)zEfunctools.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    )r
   r	   )MutableMapping
namedtuple   )recursive_repr)proxyN)allocate_lockc                       \ rS rSrSrSrg)_Link   )prevnextkey__weakref__ N)__name__
__module____qualname____firstlineno__	__slots____static_attributes__r       *lib/third_party/functools32/functools32.pyr   r      s    4Ir    r   c                   n   \ rS rSrSrS r\R                  \\	4S jr\R                  4S jr
S rS rS rSS	 jrSS
 jrS r\R$                  =rr\R(                  r\R*                  r\R,                  r\R.                  r\" 5       r\4S jrSS jr\" 5       S 5       rS rS r\ SS j5       r!S r"Sr#g)OrderedDict   z)Dictionary that remembers insertion orderc                 .   [        U5      S:  a  [        S[        U5      -  5      e U R                    U R                  " U0 UD6  g! [         aC    [	        5       U l        [        U R
                  5      =U l        nU=Ul        Ul        0 U l	         N_f = f)zInitialize an ordered dictionary.  The signature is the same as
regular dictionaries, but keyword arguments are not recommended because
their insertion order is arbitrary.

r   z$expected at most 1 arguments, got %dN)len	TypeError_OrderedDict__rootAttributeErrorr   _OrderedDict__hardroot_proxyr   r   _OrderedDict__map_OrderedDict__update)selfargskwdsroots       r!   __init__OrderedDict.__init__.   s     t9q=BSYNOO	KK 	t$t$  	#gDO!'!88DK$$((DI	DJ		s   A A
BBc                     X;  aV  U" 5       =U R                   U'   nU R                  nUR                  nXUsUl        Ul        Ul        Xhl        U" U5      Ul        U" XU5        g)z!od.__setitem__(i, y) <==> od[i]=yN)r,   r(   r   r   r   )	r.   r   valuedict_setitemr   Linklinkr1   lasts	            r!   __setitem__OrderedDict.__setitem__?   s]    
 ?%)V+DJJsOd;;D99D-1*DIty$(IdDIT&r    c                     U" X5        U R                   R                  U5      nUR                  nUR                  nXTl        XEl        g)z od.__delitem__(y) <==> del od[y]N)r,   popr   r   )r.   r   dict_delitemr8   	link_prev	link_nexts         r!   __delitem__OrderedDict.__delitem__M   s:     	Tzz~~c"II	II	""r    c              #      #    U R                   nUR                  nX!La!  UR                  v   UR                  nX!La  M   gg7f)zod.__iter__() <==> iter(od)N)r(   r   r   r.   r1   currs      r!   __iter__OrderedDict.__iter__X   9      {{yy((N99D 
   ;AAc              #      #    U R                   nUR                  nX!La!  UR                  v   UR                  nX!La  M   gg7f)z#od.__reversed__() <==> reversed(od)N)r(   r   r   rD   s      r!   __reversed__OrderedDict.__reversed__a   rH   rI   c                     U R                   nU=Ul        Ul        U R                  R	                  5         [
        R	                  U 5        g)z.od.clear() -> None.  Remove all items from od.N)r(   r   r   r,   cleardict)r.   r1   s     r!   rN   OrderedDict.clearj   s5    {{ $$	DI



4r    c                 @   U (       d  [        S5      eU R                  nU(       a%  UR                  nUR                  nX$l        XBl        O$UR                  nUR                  nXRl        X%l        UR                  nU R
                  U	 [        R                  X5      nXg4$ )zod.popitem() -> (k, v), return and remove a (key, value) pair.
Pairs are returned in LIFO order if last is true or FIFO order if false.

zdictionary is empty)KeyErrorr(   r   r   r   r,   rO   r=   )r.   r9   r1   r8   r?   r@   r   r5   s           r!   popitemOrderedDict.popitemq   s    
 011{{99D		I!N!I99D		I!I!NhhJJsO#zr    c                 *   U R                   U   nUR                  nUR                  nXTl        XEl        U R                  nU(       a'  UR                  nX#l        Xcl        U=Ul        Ul        gUR                  nXcl        Xsl        U=Ul        Ul        g)zMove an existing element to the end (or beginning if last==False).

Raises KeyError if the element does not exist.
When last=True, acts like a fast version of self[key]=self.pop(key).

N)r,   r   r   r(   )r.   r   r9   r8   r?   r@   r1   firsts           r!   move_to_endOrderedDict.move_to_end   s{     zz#II	II	""{{99DII$((DI	IIEII%))DI
r    c                     [         R                  n[        U 5      S-   nU" U R                  5      nX1" U R                  5      S-  -  nX1" U R
                  5      U-  -  nX1" U R                  5      U-  -  nU$ )Nr      )_sys	getsizeofr&   __dict__r,   r*   r(   )r.   sizeofnsizes       r!   
__sizeof__OrderedDict.__sizeof__   ss    IMdmm$tzz"Q&&t'!++t{{#a''r    c                 R    X;   a  X   nX	 U$ X R                   L a  [        U5      eU$ )zod.pop(k[,d]) -> v, remove specified key and return the corresponding
value.  If key is not found, d is returned if given, otherwise KeyError
is raised.

)_OrderedDict__markerrR   )r.   r   defaultresults       r!   r=   OrderedDict.pop   s3     ;YF	Mmm#3-r    Nc                      X;   a  X   $ X U'   U$ )zDod.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in odr   )r.   r   re   s      r!   
setdefaultOrderedDict.setdefault   s    ;9S	r    c                     U (       d  U R                   R                  < S3$ U R                   R                  < S[        U R                  5       5      < S3$ )zod.__repr__() <==> repr(od)z()())	__class__r   listitemsr.   s    r!   __repr__OrderedDict.__repr__   s:     !^^4466>>22D4FGGr    c                    U  Vs/ s H  oX   /PM
     nn[        U 5      R                  5       n[        [        5       5       H  nUR                  US5        M     U(       a  U R                  U4U4$ U R                  U44$ s  snf )z%Return state information for picklingN)varscopyr#   r=   rn   )r.   krp   	inst_dicts       r!   
__reduce__OrderedDict.__reduce__   su    '+,t!TWt,JOO%	km$AMM!T" %NNUHi88~~x'' -s   Bc                 $    U R                  U 5      $ )z!od.copy() -> a shallow copy of od)rn   rq   s    r!   rv   OrderedDict.copy   s    ~~d##r    c                 .    U " 5       nU H  nX#U'   M	     U$ )zoOD.fromkeys(S[, v]) -> New ordered dictionary with keys from S.
If not specified, the value defaults to None.

r   )clsiterabler5   r.   r   s        r!   fromkeysOrderedDict.fromkeys   s!     uCI r    c                    [        U[        5      (       aV  [        U 5      [        U5      :H  =(       a8    [        S [	        U R                  5       UR                  5       5       5       5      $ [        R                  X5      $ )zod.__eq__(y) <==> od==y.  Comparison to another OD is order-sensitive
while comparison to a regular mapping is order-insensitive.

c              3   .   #    U  H  u  pX:H  v   M     g 7fNr   ).0pqs      r!   	<genexpr>%OrderedDict.__eq__.<locals>.<genexpr>   s     I(Hqt(Hs   )
isinstancer#   r&   allziprp   rO   __eq__r.   others     r!   r   OrderedDict.__eq__   s]    
 e[))t9c%j( JIDJJL%++-(HIIJ{{4''r    )
__hardroot__map__root)Tr   )$r   r   r   r   __doc__r2   rO   r:   r+   r   rA   rF   rK   rN   rS   rW   ra   r   updater-   keysvaluesrp   __ne__objectrd   r=   ri   _recursive_reprrr   ry   rv   classmethodr   r   r   r   r    r!   r#   r#      s    /%$ "&!1!1e' -1,<,< 	#.*0 '---FXD""F  E""FxH'  H H($  (r    r#   )r   r   r   )r]   c                     Xl         U H  n [        X5      n[        XU5        M     U H'  n[        X5      R	                  [        X0 5      5        M)     U $ ! [         a     M[  f = f)a  Update 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)
)__wrapped__getattrsetattrr)   r   )wrapperwrappedassignedupdatedattrr5   s         r!   r   r      sp     "	*G*E G5)  %%ggR&@A  N  		s   A
A%$A%c                      [        [        U XS9$ )ad  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   s      r!   r   r     s     >7$7 7r    c                 x   SS 4SS 4SS 4/SS 4SS	 4SS
 4/SS 4SS 4SS 4/SS 4SS 4SS 4/S.n[        [        U 5      5      [        U5      -  nU(       d  [        S5      e[        U5      nX    H=  u  pEXB;  d  M  XEl        [        [        U5      R                  Ul        [        XU5        M?     U $ )z6Class decorator that fills in missing ordering methods__gt__c                 *    X:  =(       d    X:H  (       + $ r   r   r   s     r!   <lambda> total_ordering.<locals>.<lambda>"      t|7Tt}2Ur    __le__c                      X:  =(       d    X:H  $ r   r   r   s     r!   r   r   #      $,2O$-2Or    __ge__c                     X:  + $ r   r   r   s     r!   r   r   $      d2Br    c                 "    X::  + =(       d    X:H  $ r   r   r   s     r!   r   r   %  s    d2C2Tt}2Tr    __lt__c                 "    X:*  =(       a    X:X  + $ r   r   r   s     r!   r   r   &      $-2UDU2Ur    c                     X::  + $ r   r   r   s     r!   r   r   '      d2Cr    c                 *    X:  =(       d    X:H  (       + $ r   r   r   s     r!   r   r   (  r   r    c                      X:  =(       d    X:H  $ r   r   r   s     r!   r   r   )  r   r    c                     X:  + $ r   r   r   s     r!   r   r   *  r   r    c                 "    X:  + =(       d    X:H  $ r   r   r   s     r!   r   r   +  s    t3D2V2Vr    c                 "    X:  =(       a    X:X  + $ r   r   r   s     r!   r   r   ,  r   r    c                     X:  + $ r   r   r   s     r!   r   r   -  r   r    )r   r   r   r   z6must define at least one ordering operation: < > <= >=)	setdir
ValueErrormaxr   r   intr   r   )r~   convertrootsr1   opnameopfuncs         r!   r   r     s    UVOPBCE TUUVCDF UVOPBCE VWUVCDFG CMCL(EQRRu:D!-$O$S&199FNC(	 (
 Jr    c                 ,   ^   " U 4S jS[         5      nU$ )z,Convert a cmp= function into a key= functionc                   n   > \ rS rSrS/rS rU 4S jrU 4S jrU 4S jrU 4S jr	U 4S jr
U 4S	 jrS
rSrg
)zcmp_to_key.<locals>.Ki<  objc                     Xl         g r   r   )r.   r   s     r!   r2   cmp_to_key.<locals>.K.__init__>  s    Hr    c                 D   > T" U R                   UR                   5      S:  $ Nr   r   r.   r   mycmps     r!   r   cmp_to_key.<locals>.K.__lt__@      599-11r    c                 D   > T" U R                   UR                   5      S:  $ r   r   r   s     r!   r   cmp_to_key.<locals>.K.__gt__B  r   r    c                 D   > T" U R                   UR                   5      S:H  $ r   r   r   s     r!   r   cmp_to_key.<locals>.K.__eq__D      599-22r    c                 D   > T" U R                   UR                   5      S:*  $ r   r   r   s     r!   r   cmp_to_key.<locals>.K.__le__F  r   r    c                 D   > T" U R                   UR                   5      S:  $ r   r   r   s     r!   r   cmp_to_key.<locals>.K.__ge__H  r   r    c                 D   > T" U R                   UR                   5      S:g  $ r   r   r   s     r!   r   cmp_to_key.<locals>.K.__ne__J  r   r    Nr   )r   r   r   r   r   r2   r   r   r   r   r   r   __hash__r   )r   s   r!   Kcmp_to_key.<locals>.K<  s2    G			2	2	3	3	3	3r    r   )r   )r   r   s   ` r!   r   r   :  s    F " Hr    	CacheInfozhits misses maxsize currsizec                 @   ^  [         [        [        [        4U 4S jjnU$ )a  Least-recently-used cache decorator.

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

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

c                 n  >^ ^^^^^^	^
^^^^ S/S/smm[        5       4m[        5       mTc&  [        5       m[        T 5      UUUUUUUU 4S j5       nOB[	        5       mTR
                  m	TR                  m
[        T 5      UUU	U
UUUUUUUUU 4S j5       nUUUUUU4S jnUUUU4S jnXel        Xul        U$ )Nr   c                     > U nU(       a"  UTT
" T	" UR                  5       5      5      -   -  n TU   nTS==   S-  ss'   U$ ! T a     Of = fT" U 0 UD6nUTU'   TS==   S-  ss'   U$ Nr   r   rp   )r/   r0   r   rf   rR   cachehitskwd_markmissessortedtupleuser_functions       r!   r   7lru_cache.<locals>.decorating_function.<locals>.wrappero  s    8eF4::<,@&AAAC"3ZFGqLG!M &55#c
q	Q	s   A A
Ac                    > U nU(       a"  UT	T" T" UR                  5       5      5      -   -  nT    TU   nT" U5        TS==   S-  ss'   UsS S S 5        $ ! T a     Of = f S S S 5        O! , (       d  f       O= fT" U 0 UD6nT   UTU'   TS==   S-  ss'   T
" T5      T:  a  T" S5        S S S 5        U$ ! , (       d  f       U$ = fr   r   )r/   r0   r   rf   rR   r   cache_popitemcache_renewr   r   r&   lockmaxsizer   r   r   r   s       r!   r   r     s    8eF4::<,@&AAAC!&s#C(Q1% T $  TT '55!'E#J1INI5zG+%a(	 
  T
 s4   A,AAA,AA,,
A:'B88
Cc            	      r   > T   [        TS   TS   TT" T 5      5      sSSS5        $ ! , (       d  f       g= f)zReport cache statisticsr   N)
_CacheInfo)r   r   r&   r   r   r   s   r!   
cache_info:lru_cache.<locals>.decorating_function.<locals>.cache_info  s*    !$q'6!9gs5zJ s   (
6c                  r   > T   T R                  5         S=TS'   TS'   SSS5        g! , (       d  f       g= f)z$Clear the cache and cache statisticsr   N)rN   )r   r   r   r   s   r!   cache_clear;lru_cache.<locals>.decorating_function.<locals>.cache_clear  s+    &''Q&) s   (
6)	r   LockrO   r   r#   rS   rW   r   r   )r   r   r   r&   rR   r   r   r   r   r   r   r   r   r   r   r   s   `````   @@@@@@@r!   decorating_function&lru_cache.<locals>.decorating_functione  s     sQCfH;v?FE=!  "  ME!MMM++K=!   "(	K 	K
	( 	( ()r    )r   r   r&   rR   )r   r   s   ` r!   r   r   Q  s    * Fh@D r    )d   )!r   __all__
_functoolsr
   r	   collectionsr   r   	reprlib32r   r   weakrefr   r+   sysr[   threadr   r   ImportError_dummy_thread32r   r   rO   r#   r   r   r   r   r   r   r   r   r   r    r!   <module>r	     s   M ' 2 8 # 7,5F 5O($ O(h <  2,: )#76* %CD
Vy	  767s   A+ +A:9A: