B JQ @sdddddddddd d g Zyd d lmZWnek r>YnXd d lmZd dlmZd dlm Z d dl m Z dZ dZ e e fddZe e fddZefddZefddZefddZefddZefddZefdd Zefd!d"Zefd#d$Zefd%d&Zefd'd(Zefd)d*Zefd+d,Zd-efd.efd/efgd/efd0efd-efgd0efd/efd.efgd.efd-efd0efgd1Zd2dZd3dZyd d4lmZWnek rYnXGd5ddZ yd d6lm Z Wnek rYnXGd7d d e!Z"ed8d9d:d;dd>e$Z%e!fe&e'he(e)e*fd?d@Z+dQdCdZ,dDdEZ-yd dFlm-Z-Wnek rnYnXdGdHZ.dRdJdKZ/dLdMZ0dNdOZ1dPd Z2dIS)Supdate_wrapperwrapsWRAPPER_ASSIGNMENTSWRAPPER_UPDATEStotal_ordering cmp_to_key lru_cachereducepartial partialmethodsingledispatch)r)get_cache_token) namedtuple)recursive_repr)RLock) __module____name__ __qualname____doc____annotations__)__dict__c Csnx<|D]4}yt||}Wntk r,YqXt|||qWx$|D]}t||t||iqDW||_|S)N)getattrAttributeErrorsetattrupdate __wrapped__)wrapperwrappedassignedupdatedattrvaluer",/opt/alt/python37/lib/python3.7/functools.pyr%s  cCstt|||dS)N)rrr)r r)rrrr"r"r#rCs cCs$||}||kr|S| o"||kS)N)__lt__)selfotherNotImplemented op_resultr"r"r# _gt_from_lt[s r)cCs||}|p||kS)N)r$)r%r&r'r(r"r"r# _le_from_ltbs r*cCs||}||kr|S| S)N)r$)r%r&r'r(r"r"r# _ge_from_ltgs r+cCs$||}||kr|S| p"||kS)N)__le__)r%r&r'r(r"r"r# _ge_from_lens r-cCs"||}||kr|S|o ||kS)N)r,)r%r&r'r(r"r"r# _lt_from_leus r.cCs||}||kr|S| S)N)r,)r%r&r'r(r"r"r# _gt_from_le|s r/cCs$||}||kr|S| o"||kS)N)__gt__)r%r&r'r(r"r"r# _lt_from_gts r1cCs||}|p||kS)N)r0)r%r&r'r(r"r"r# _ge_from_gts r2cCs||}||kr|S| S)N)r0)r%r&r'r(r"r"r# _le_from_gts r3cCs$||}||kr|S| p"||kS)N)__ge__)r%r&r'r(r"r"r# _le_from_ges r5cCs"||}||kr|S|o ||kS)N)r4)r%r&r'r(r"r"r# _gt_from_ges r6cCs||}||kr|S| S)N)r4)r%r&r'r(r"r"r# _lt_from_ges r7r0r,r4r$)r$r,r0r4csZfddtD}|stdt|}x.t|D]"\}}||kr0||_t||q0WS)Ncs(h|] }t|dtt|dk r|qS)N)robject).0op)clsr"r# sz!total_ordering..z6must define at least one ordering operation: < > <= >=)_convert ValueErrormaxrr)r;rootsrootopnameopfuncr")r;r#rscsGfdddt}|S)NcsZeZdZdgZddZfddZfddZfdd Zfd d Zfd d Z dZ dS)zcmp_to_key..KobjcSs ||_dS)N)rD)r%rDr"r"r#__init__szcmp_to_key..K.__init__cs|j|jdkS)Nr )rD)r%r&)mycmpr"r#r$szcmp_to_key..K.__lt__cs|j|jdkS)Nr )rD)r%r&)rFr"r#r0szcmp_to_key..K.__gt__cs|j|jdkS)Nr )rD)r%r&)rFr"r#__eq__szcmp_to_key..K.__eq__cs|j|jdkS)Nr )rD)r%r&)rFr"r#r,szcmp_to_key..K.__le__cs|j|jdkS)Nr )rD)r%r&)rFr"r#r4szcmp_to_key..K.__ge__N) rrr __slots__rEr$r0rGr,r4__hash__r")rFr"r#Ks     rJ)r8)rFrJr")rFr#rs)rcsFeZdZdZfddZddZeddZdd Zd d Z Z S) r )funcargskeywordsr __weakref__cs|s tdt|dkr td|^}}}t|s:tdt|}t|drv|j|}|j}|||}~|j }t t | |}||_ ||_||_|S)Nz1descriptor '__new__' of partial needs an argumentz*type 'partial' takes at least one argumentz#the first argument must be callablerK) TypeErrorlencallabletuplehasattrrLrMcopyrrKsuperr __new__)rLrMr;rKZtmpkwr%) __class__r"r#rWs(      zpartial.__new__cOs:|s td|^}}|j}|||j|j||S)Nz2descriptor '__call__' of partial needs an argument)rPrMrUrrKrL)rLrMr%Z newkeywordsr"r"r#__call__ s   zpartial.__call__cCst|j}t|jg}|dd|jD|dd|jDt|jdkrld|dd |dS|dd |dS) Ncss|]}t|VqdS)N)repr)r9xr"r"r# sz#partial.__repr__..css |]\}}|d|VqdS)=Nr")r9kvr"r"r#r\s functoolsz functools.(z, )) typerrZrKextendrLrMitemsrjoin)r%qualnamerLr"r"r#__repr__s  zpartial.__repr__cCs*t||jf|j|j|jpd|jp$dffS)N)rcrKrLrMr)r%r"r"r# __reduce__szpartial.__reduce__cCst|tstdt|dkr0tdt||\}}}}t|rrt|trr|dk r`t|trr|dk rzt|tsztdt|}|dkri}nt|tk rt|}|dkri}||_||_||_ ||_ dS)Nz(argument to __setstate__ must be a tuplezexpected 4 items in state, got zinvalid partial state) isinstancerSrPrQrRdictrcrrKrLrM)r%staterKrLkwds namespacer"r"r# __setstate__ s(    zpartial.__setstate__) rrrrHrWrYrrhrirp __classcell__r"r")rXr#r s   )r c@s8eZdZddZddZddZddZed d Zd S) r cOst|dkr|^}}}n>|s&tdn0d|krB|d}|^}}ntdt|dt|}t|s~t|ds~td|t|tr|j |_ |j ||_ |j |_ |j |n||_ ||_ ||_ dS)NrOz8descriptor '__init__' of partialmethod needs an argumentrKz8type 'partialmethod' takes at least one argument, got %d__get__z${!r} is not callable or a descriptor)rQrPpoprSrRrTformatrkr rKrLrMrUr)rLrMr%rKr"r"r#rEFs*        zpartialmethod.__init__cCsNdtt|j}ddd|jD}d}|j|jj|jj |j ||dS)Nz, css|]\}}d||VqdS)z{}={!r}N)ru)r9r^r_r"r"r#r\isz)partialmethod.__repr__..z*{module}.{cls}({func}, {args}, {keywords}))moduler;rKrLrM) rfmaprZrLrMrerurXrrrK)r%rLrM format_stringr"r"r#rhgs  zpartialmethod.__repr__csfdd}j|_|_|S)Ncs<j}|||^}}|fjt|}j||S)N)rMrUrrLrSrK)rLrM call_keywords cls_or_selfrest call_args)r%r"r#_methodss   z3partialmethod._make_unbound_method.._method)__isabstractmethod___partialmethod)r%r}r")r%r#_make_unbound_methodrs z"partialmethod._make_unbound_methodcCst|jdd}d}|dk rd|||}||jk rdt|f|j|j}y |j|_Wntk rbYnX|dkr||||}|S)Nrs) rrKr rLrM__self__rrrs)r%rDr;getresultnew_funcr"r"r#rs}s   zpartialmethod.__get__cCst|jddS)Nr~F)rrK)r%r"r"r#r~sz"partialmethod.__isabstractmethod__N) rrrrErhrrspropertyr~r"r"r"r#r >s !   CacheInfohitsmissesmaxsizecurrsizec@s$eZdZdZefddZddZdS) _HashedSeq hashvaluecCs||dd<|||_dS)N)r)r%tuphashr"r"r#rEs z_HashedSeq.__init__cCs|jS)N)r)r%r"r"r#rIsz_HashedSeq.__hash__N)rrrrHrrErIr"r"r"r#rs rc s|}|r*||7}x|D] } || 7}qW|rl||fdd|D7}|r||fdd|D7}n$||dkr|d|kr|dSt|S)Nc3s|]}|VqdS)Nr")r9r_)rcr"r#r\sz_make_key..c3s|]}|VqdS)Nr")r9r_)rcr"r#r\srrr )revaluesr) rLrntypedkwd_mark fasttypesrSrcrQkeyitemr")rcr# _make_keys  rFcs:ttrdkr(dndk r(tdfdd}|S)Nr z)Expected maxsize to be an integer or Nonecst|t}t||S)N)_lru_cache_wrapper _CacheInfor) user_functionr)rrr"r#decorating_functionsz&lru_cache..decorating_function)rkintrP)rrrr")rrr#rs cstt d\id djjt gddgdd< dkrh fdd}nN dkr fdd}n* fdd} fdd } fd d }||_||_|S) N)r rrrOr Fcsd7||}|S)Nrrr")rLrnr)rrr"r#rs z#_lru_cache_wrapper..wrappercsH||}|}|k r*d7|Sd7||}||<|S)Nrrr")rLrnrr)cache cache_getrmake_keyrsentinelrrr"r#r s   c s2 ||} n|}|dk rr|\}}}}||<||< }||< <||< |<d7|S d7 WdQRX||} |krnr } || <|| <|  } } d < <| =| |<n6 }| ||g}||< <|< kWdQRX|S)Nrrr") rLrnrlinkZ link_prevZ link_nextZ_keyrZlastZoldrootZoldkeyZ oldresult)KEYNEXTPREVRESULTrr cache_lenfullrlockrrrrArrr"r#rsB     c s SQRXdS)Nr"r")rrrrrrr"r# cache_infoTsz&_lru_cache_wrapper..cache_infoc s<.ddgdd<ddWdQRXdS)Nr F)clearr")rrrrrrAr"r# cache_clearYs z'_lru_cache_wrapper..cache_clear)r8rr__len__rrr)rrrrrrrr")rrrrrrrrrrrrrrrArrrr#rs* *9 r)rcCsg}xdd|D}|s|Sx:|D]2}|d}x$|D]}||ddkr4d}Pq4WPq"W|dkrhtd||x|D]}|d|krx|d=qxWqWdS)NcSsg|] }|r|qSr"r")r9sr"r"r# xsz_c3_merge..r rrzInconsistent hierarchy) RuntimeErrorappend) sequencesrs1 candidates2seqr"r"r# _c3_mergeps$     rNc s$x8tt|jD]"\}tdrt|j|}PqWd}rFtngt|jd|}g}t|j|d}x8D]0t|rxtfdd|jDsx|qxWx|D] qWfdd|D}fdd|D}fdd|D} t |gg||| |g|g|gS) N__abstractmethods__r c3s|]}t|VqdS)N) issubclass)r9b)baser"r#r\sz_c3_mro..csg|]}t|dqS))abcs)_c3_mro)r9r)rr"r#rsz_c3_mro..csg|]}t|dqS))r)r)r9r)rr"r#rscsg|]}t|dqS))r)r)r9r)rr"r#rs) enumeratereversed __bases__rTrQlistranyrremover) r;riboundaryexplicit_basesabstract_bases other_basesexplicit_c3_mrosabstract_c3_mros other_c3_mrosr")rrr#rs(    rcstjfddfddDfddfddDtg}xD]}g}x<|D]0}|krlt|rl|fdd|jDqlW|s||qZ|jtd d x,|D]$}x|D]}||kr||qWqWqZWt|d S) Ncs|kot|dot|S)N__mro__)rTr)typ)basesr;r"r# is_relatedsz _compose_mro..is_relatedcsg|]}|r|qSr"r")r9n)rr"r#rsz _compose_mro..cs(x"D]}||kr||jkrdSqWdS)NTF)r)rr&)typesr"r#is_strict_bases z$_compose_mro..is_strict_basecsg|]}|s|qSr"r")r9r)rr"r#rscsg|]}|kr|qSr"r")r9r)type_setr"r#rsT)rreverse)r)setr__subclasses__rrsortrQr)r;rmrorfoundsubsubclsr")rr;rrrrr# _compose_mros*      rcCsvt||}d}xX|D]P}|dk r\||krZ||jkrZ||jkrZt||sZtd||P||kr|}qW||S)NzAmbiguous dispatch: {} or {})rkeysrrrrur)r;registryrmatchtr"r"r# _find_impls     rcsddl}ddl}i|dfddd fdd fdd}t|dd |t<|_|_||_j |_ t |||S) Nr c s|dk r"t}|kr"|y |}WnHtk rvy |}Wntk rht|}YnX||<YnX|S)N)r rKeyErrorr)r; current_tokenimpl) cache_tokendispatch_cacherr"r#dispatch s  z singledispatch..dispatchcs|dkrhttr fddStdi}|s@tdd}ddlm}tt||\}|<dkrt drt  |S) Ncs |S)Nr")f)r;registerr"r#-z2singledispatch..register..rz(Invalid first argument to `register()`: zS. Use either `@register(some_class)` or plain `@register` on an annotated function.r )get_type_hintsr) rkrcrrPtypingrnextiterrerTr r)r;rKannrargname)rrrr)r;r#r$s   z singledispatch..registercs&|std|dj||S)Nz( requires at least 1 positional argumentr )rPrX)rLkw)rfuncnamer"r#rCszsingledispatch..wrapperrzsingledispatch function)N) rweakrefWeakKeyDictionaryrr8rrMappingProxyTyperr _clear_cacher)rKrrrr")rrrrrrr#r s    )rF)N)3__all__ _functoolsr ImportErrorabcr collectionsrreprlibr_threadrrrrrr'r)r*r+r-r.r/r1r2r3r5r6r7r=rrr r8r rrrrstrrSrcrQrrrrrrrr r"r"r"r# s                   N[ (t -)