U e5d @sdddddddddd d d d g Zd dlmZd dlmZd dlmZd dlmZdZ dZ e e fddZ e e fddZ e fddZe fddZe fddZe fddZe fddZe fd d!Ze fd"d#Ze fd$d%Ze fd&d'Ze fd(d)Ze fd*d+Ze fd,d-Zd.efd/efd0efgd0efd1efd.efgd1efd0efd/efgd/efd.efd1efgd2Zd3dZd4dZzd d5lmZWnek rYnXeZ e fd6dZ!zd d7lm!Z!Wnek rYnXGd8ddZ"zd d9lm"Z"Wnek rYnXGd:d d eZ#d;d<Z$ed=d>d?d@dAgZ%GdBdCdCe&Z'efe(e)he*e+e,fdDdEZ-dXdHdZ.dIdJZ/zd dKlm/Z/Wnek rYnXdLdMZ0dYdOdPZ1dQdRZ2dSdTZ3dUd Z4GdVd d Z5eZ6GdWd d Z7dNS)Zupdate_wrapperwrapsWRAPPER_ASSIGNMENTSWRAPPER_UPDATEStotal_ordering cmp_to_key lru_cachereducepartial partialmethodsingledispatchsingledispatchmethodcached_property)get_cache_token) namedtuple)recursive_repr)RLock) __module____name__ __qualname____doc____annotations__)__dict__c Csf|D]4}zt||}Wntk r*YqXt|||q|D]}t||t||iq>||_|SN)getattrAttributeErrorsetattrupdate __wrapped__)wrapperwrappedassignedupdatedattrvaluer%!/usr/lib64/python3.8/functools.pyr"scCstt|||dS)Nr r!r")r rr'r%r%r&r@s cCs$||}||kr|S| o"||kSr__lt__selfotherNotImplemented op_resultr%r%r& _gt_from_ltXs r/cCs||}|p||kSrr(r*r%r%r& _le_from_lt_s r0cCs||}||kr|S| Srr(r*r%r%r& _ge_from_ltds r1cCs$||}||kr|S| p"||kSr__le__r*r%r%r& _ge_from_leks r4cCs"||}||kr|S|o ||kSrr2r*r%r%r& _lt_from_lers r5cCs||}||kr|S| Srr2r*r%r%r& _gt_from_leys r6cCs$||}||kr|S| o"||kSr__gt__r*r%r%r& _lt_from_gts r9cCs||}|p||kSrr7r*r%r%r& _ge_from_gts r:cCs||}||kr|S| Srr7r*r%r%r& _le_from_gts r;cCs$||}||kr|S| p"||kSr__ge__r*r%r%r& _le_from_ges r>cCs"||}||kr|S|o ||kSrr<r*r%r%r& _gt_from_ges r?cCs||}||kr|S| Srr<r*r%r%r& _lt_from_ges r@r8r3r=r))r)r3r8r=csVfddtD}|stdt|}t|D]"\}}||kr.||_t||q.S)Ncs(h|] }t|dtt|dk r|qSr)robject).0opclsr%r& sz!total_ordering..z6must define at least one ordering operation: < > <= >=)_convert ValueErrormaxrr)rErootsrootopnameopfuncr%rDr&rscsGfdddt}|S)NcsZeZdZdgZddZfddZfddZfdd Zfd d Zfd d Z dZ dS)zcmp_to_key..KobjcSs ||_dSrrN)r+rNr%r%r&__init__szcmp_to_key..K.__init__cs|j|jdkSNrrOr+r,mycmpr%r&r)szcmp_to_key..K.__lt__cs|j|jdkSrQrOrRrSr%r&r8szcmp_to_key..K.__gt__cs|j|jdkSrQrOrRrSr%r&__eq__szcmp_to_key..K.__eq__cs|j|jdkSrQrOrRrSr%r&r3szcmp_to_key..K.__le__cs|j|jdkSrQrOrRrSr%r&r=szcmp_to_key..K.__ge__N) rrr __slots__rPr)r8rUr3r=__hash__r%rSr%r&Ks     rX)rA)rTrXr%rSr&rs)rcCsZt|}|tkr>z t|}WqBtk r:tddYqBXn|}|D]}|||}qF|S)Nz0reduce() of empty sequence with no initial value)iter_initial_missingnext StopIteration TypeError)ZfunctionZsequenceinitialitr$Zelementr%r%r&rs   )rcsFeZdZdZfddZddZeddZdd Zd d Z Z S) r )funcargskeywordsr __weakref__csZt|stdt|dr4|j|}|j|}|j}tt||}||_||_||_|S)Nz#the first argument must be callabler`) callabler]hasattrrarbr`superr __new__)rEr`rarbr+ __class__r%r&rgs   zpartial.__new__cOs|j|}|j|j||Srrbr`ra)r+rarbr%r%r&__call__%s zpartial.__call__cCst|j}t|jg}|dd|jD|dd|jDt|jdkrld|dd |dS|dd |dS) Ncss|]}t|VqdSr)repr)rBxr%r%r& -sz#partial.__repr__..css |]\}}|d|VqdS)=Nr%rBkvr%r%r&rn.s functoolsz functools.(, )) typerrlr`extendrarbitemsrjoin)r+qualnamerar%r%r&__repr__)s  zpartial.__repr__cCs*t||jf|j|j|jpd|jp$dffSr)rwr`rarbrr+r%r%r& __reduce__3szpartial.__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) isinstancetupler]lenrddictrwrr`rarb)r+stater`rakwds namespacer%r%r& __setstate__7s4    zpartial.__setstate__) rrrrVrgrkrr|r~r __classcell__r%r%rhr&r s  )r c@s@eZdZddZde_ddZddZd d d Zed d Z dS)r cOst|dkr|^}}}nV|s&tdnHd|krZ|d}|^}}ddl}|jdtddntdt|dt|}t|st|d std |t |t r|j |_ |j ||_ |j||_n||_ ||_ ||_dS) Nz8descriptor '__init__' of partialmethod needs an argumentr`rz0Passing 'func' as keyword argument is deprecated) stacklevelz8type 'partialmethod' takes at least one argument, got %d__get__z${!r} is not callable or a descriptor)rr]popwarningswarnDeprecationWarningrrdreformatrr r`rarb)rarbr+r`rr%r%r&rP]s6       zpartialmethod.__init__z#($self, func, /, *args, **keywords)cCsNdtt|j}ddd|jD}d}|j|jj|jj |j ||dS)Nrucss|]\}}d||VqdS)z{}={!r}N)rrpr%r%r&rnsz)partialmethod.__repr__..z*{module}.{cls}({func}, {args}, {keywords}))modulerEr`rarb) rzmaprlrarbryrrirrr`)r+rarb format_stringr%r%r&r|s  zpartialmethod.__repr__csfdd}j|_|_|S)Ncs j|}j|fj||Srrj) cls_or_selfrarbr}r%r&_methods z3partialmethod._make_unbound_method.._method)__isabstractmethod___partialmethod)r+rr%r}r&_make_unbound_methods z"partialmethod._make_unbound_methodNcCst|jdd}d}|dk rd|||}||jk rdt|f|j|j}z |j|_Wntk rbYnX|dkr||||}|S)Nr) rr`r rarb__self__rrr)r+rNrEgetresultnew_funcr%r%r&rs   zpartialmethod.__get__cCst|jddSNrFrr`r}r%r%r&rsz"partialmethod.__isabstractmethod__)N) rrrrP__text_signature__r|rrpropertyrr%r%r%r&r Us"  cCst|tr|j}q|Sr)rr r`r`r%r%r&_unwrap_partials r CacheInfohitsmissesmaxsizecurrsizec@s$eZdZdZefddZddZdS) _HashedSeq hashvaluecCs||dd<|||_dSrr)r+tuphashr%r%r&rPs z_HashedSeq.__init__cCs|jSrrr}r%r%r&rWsz_HashedSeq.__hash__N)rrrrVrrPrWr%r%r%r&rs rc s|}|r&||7}|D] } || 7}q|rh||fdd|D7}|r||fdd|D7}n$||dkr|d|kr|dSt|S)Nc3s|]}|VqdSrr%rBrrrwr%r&rnsz_make_key..c3s|]}|VqdSrr%rrr%r&rnsrr)ryvaluesr) rartypedkwd_mark fasttypesrrwrkeyitemr%rr& _make_keys   rFcsnttrdkr\dnDtrLttrLd}t|t}t||Sdk r\tdfdd}|S)Nrrz=Expected first argument to be an integer, a callable, or Nonecst|t}t||Sr)_lru_cache_wrapper _CacheInfor) user_functionrrrr%r&decorating_function sz&lru_cache..decorating_function)rintrdboolrrrr])rrrrrr%rr&rs   cstt d\id djjt gddgdd< dkrh fdd}nN dkr fdd}n* fdd} fdd } fd d }||_||_|S) N)rrrrFcsd7||}|SNrr%)rarr)rrr%r&r$s z#_lru_cache_wrapper..wrappercsH||}|}|k r*d7|Sd7||}||<|Srr%)rarrr)cache cache_getrmake_keyrsentinelrrr%r&r-s   c s> ||} z|}|dk r~|\}}}}||<||< }||< <||< |<d7|W5QRS d7 W5QRX||} |krnr } || <|| <|  } } d < <| =| |<n6 }| ||g}||< <|< kW5QRX|Srr%) rarrlinkZ link_prevZ link_nextZ_keyrZlastZoldrootZoldkeyZ oldresult)KEYNEXTPREVRESULTrr cache_lenfullrlockrrrrKrrr%r&r<sB     c s,W5QRSQRXdSrr%r%)rrrrrrr%r& cache_infousz&_lru_cache_wrapper..cache_infoc s<.ddgdd<ddW5QRXdS)NrF)clearr%)rrrrrrKr%r& cache_clearzs z'_lru_cache_wrapper..cache_clear)rArr__len__rrr)rrrrrrrr%)rrrrrrrrrrrrrrrKrrrr&rs* *9 r)rcCsg}dd|D}|s|S|D]2}|d}|D]}||ddkr.d}qq.qRq|dkrbtd|||D]}|d|krp|d=qpqdS)NcSsg|] }|r|qSr%r%rBsr%r%r& sz_c3_merge..rrzInconsistent hierarchy) RuntimeErrorappend) sequencesrs1 candidates2seqr%r%r& _c3_merges"  rNc stt|jD]$\}tdrt|j|}q8qd}rDtngt|jd|}g}t|j|d}D]0t|rttfdd|jDst|qt|D] qfdd|D}fdd|D}fdd|D} t |gg||| |g|g|gS) N__abstractmethods__rc3s|]}t|VqdSr) issubclass)rBb)baser%r&rnsz_c3_mro..csg|]}t|dqSabcs_c3_mrorBrrr%r&rsz_c3_mro..csg|]}t|dqSrrrrr%r&rscsg|]}t|dqSrrrrr%r&rs) enumeratereversed __bases__rerlistranyrremover) rEriboundaryexplicit_basesabstract_bases other_basesexplicit_c3_mrosabstract_c3_mros other_c3_mrosr%)rrr&rsD   rcstjfddfddDfddfddDtg}D]}g}|D]0}|krht|rh|fdd|jDqh|s||qX|jtd d |D] }|D]}||kr||qqqXt|d S) Ncs|kot|dot|S)N__mro__)rer)typ)basesrEr%r& is_relatedsz _compose_mro..is_relatedcsg|]}|r|qSr%r%rBn)rr%r&rsz _compose_mro..cs&D]}||kr||jkrdSqdS)NTF)r)rr,)typesr%r&is_strict_basesz$_compose_mro..is_strict_basecsg|]}|s|qSr%r%r)rr%r&rscsg|]}|kr|qSr%r%r)type_setr%r&rsT)rreverser)setr__subclasses__rrsortrr)rErmrorfoundsubsubclsr%)rrErrrrr& _compose_mros*    rcCstt||}d}|D]R}|dk r\||krX||jkrX||jkrXt||sXtd||qj||kr|}q||S)NzAmbiguous dispatch: {} or {})rkeysrrrrr)rEregistryrmatchtr%r%r& _find_impls" r csddl}ddl}i|dfddd fdd fdd}t|dd |t<|_|_||_j |_ t |||S) Nrc s|dk r"t}|kr"|z |}WnHtk rvz |}Wntk rht|}YnX||<YnX|Sr)rrKeyErrorr )rE current_tokenimpl) cache_tokendispatch_cacherr%r&dispatch.s  z singledispatch..dispatchcs|dkrttr fddStdi}|s@tdd}ddlm}tt||\}ttstd|d d |<dkrt d rt  |S) Ncs |Srr%)f)rEregisterr%r&Nz2singledispatch..register..rz(Invalid first argument to `register()`: zS. Use either `@register(some_class)` or plain `@register` on an annotated function.r)get_type_hintszInvalid annotation for z. z is not a class.r) rrwrr]typingrr[rYryrerr)rEr`annrargname)rrrrrDr&rEs(     z singledispatch..registercs&|std|dj||S)Nz( requires at least 1 positional argumentr)r]ri)rakw)rfuncnamer%r&rfszsingledispatch..wrapperrzsingledispatch function)N) rweakrefWeakKeyDictionaryrrArrMappingProxyTyperr _clear_cacher)r`rrrr%)rrrrrrr&r s !   c@s4eZdZddZd ddZd ddZedd ZdS) r cCs4t|s t|ds t|dt||_||_dS)Nrz is not callable or a descriptor)rdrer]r dispatcherr`r+r`r%r%r&rPs zsingledispatchmethod.__init__NcCs|jj||dS)Nr)rr)r+rEmethodr%r%r&rszsingledispatchmethod.registercs0fdd}j|_j|_t|j|S)Ncs$j|dj}|||SrQ)rrrir)rakwargsr!rErNr+r%r&rsz-singledispatchmethod.__get__.._method)rrrr`)r+rNrErr%r#r&rs  zsingledispatchmethod.__get__cCst|jddSrrr}r%r%r&rsz)singledispatchmethod.__isabstractmethod__)N)N)rrrrPrrrrr%r%r%r&r xs   c@s&eZdZddZddZdddZdS) r cCs ||_d|_|j|_t|_dSr)r`attrnamerrrr r%r%r&rPszcached_property.__init__cCs8|jdkr||_n"||jkr4td|jd|ddS)Nz?Cannot assign the same cached_property to two different names (z and z).)r$r])r+ownernamer%r%r& __set_name__s   zcached_property.__set_name__Nc Cs|dkr |S|jdkrtdz |j}Wn8tk r`dt|jd|jd}t|dYnX||jt}|tkr|jn||jt}|tkr| |}z|||j<Wn8tk rdt|jd|jd}t|dYnXW5QRX|S)NzGCannot use cached_property instance without calling __set_name__ on it.zNo '__dict__' attribute on z instance to cache z property.zThe '__dict__' attribute on z7 instance does not support item assignment for caching ) r$r]rrrwrr _NOT_FOUNDrr`)r+instancer%rmsgvalr%r%r&rs2   zcached_property.__get__)N)rrrrPr'rr%r%r%r&r s )rF)N)8__all__abcr collectionsrreprlibr_threadrrrrrr-r/r0r1r4r5r6r9r:r;r>r?r@rGrr _functools ImportErrorrArZrr r rrrrrstrrrwrrrrrrrr r r r(r r%r%r%r& s                   AX   ,t -)\(