a Z^sc@sgdZddlmZddlmZddlmZddlmZddl m Z dZ dZ e e fd d Z e e fd d Zefd dZefddZefddZefddZefddZefddZefddZefddZefddZefdd Zefd!d"Zefd#d$Zd%efd&efd'efgd'efd(efd%efgd(efd'efd&efgd&efd%efd(efgd)Zd*d+Zd,d-Zzdd.lmZWne yYn0e!Z"e"fd/d0Z#zdd1lm#Z#Wne yYn0Gd2d3d3Z$zdd4lm$Z$Wne yYn0Gd5d6d6e!Z%d7d8Z&ed9gd:Z'Gd;d<dZ/dWdAdBZ0dCdDZ1zddElm1Z1Wne yxYn0dFdGZ2dHdIZ3dXdKdLZ4dMdNZ5dOdPZ6dQdRZ7GdSdTdTZ8e!Z9GdUdVdVZ:dJS)Y)update_wrapperwrapsWRAPPER_ASSIGNMENTSWRAPPER_UPDATEStotal_orderingcache cmp_to_key lru_cachereducepartial partialmethodsingledispatchsingledispatchmethodcached_property)get_cache_token) namedtuple)recursive_repr)RLock) GenericAlias) __module____name__ __qualname____doc____annotations__)__dict__c Csd|D]2}zt||}Wnty(Yq0t|||q|D]}t||t||iq<||_|SN)getattrAttributeErrorsetattrZupdateZ __wrapped__)wrapperwrappedassignedupdatedZattrvaluer#!/usr/lib64/python3.9/functools.pyr#s rcCstt|||dS)Nrr r!)r rr%r#r#r$rAs rcC$||}||ur|S| o"||kSr__lt__selfotherNotImplementedZ op_resultr#r#r$ _gt_from_ltY r-cC"||}||ur|S|p ||kSrr'r)r#r#r$ _le_from_lt`r.r0cC||}||ur|S| Srr'r)r#r#r$ _ge_from_ltgr.r2cC$||}||ur|S| p"||kSr__le__r)r#r#r$ _ge_from_lenr.r6cC"||}||ur|S|o ||kSrr4r)r#r#r$ _lt_from_leur.r8cCr1rr4r)r#r#r$ _gt_from_le|r.r9cCr&r__gt__r)r#r#r$ _lt_from_gtr.r<cCr/rr:r)r#r#r$ _ge_from_gtr.r=cCr1rr:r)r#r#r$ _le_from_gtr.r>cCr3r__ge__r)r#r#r$ _le_from_ger.rAcCr7rr?r)r#r#r$ _gt_from_ger.rBcCr1rr?r)r#r#r$ _lt_from_ger.rCr;r5r@r()r(r5r;r@csVfddtD}|stdt|}t|D]"\}}||vr.||_t||q.S)Ncs(h|] }t|dtt|dur|qSr)robject).0Zopclsr#r$Z z!total_ordering..z6must define at least one ordering operation: < > <= >=)_convertZ ValueErrorZmaxrr)rGZrootsrootZopnameZopfuncr#rFr$rsrcsGfdddt}|S)NcsZeZdZdgZddZfddZfddZfdd Zfd d Zfd d Z dZ dS)zcmp_to_key..KobjcSs ||_dSrrK)r*rKr#r#r$__init__zcmp_to_key..K.__init__cs|j|jdkSNrrLr*r+mycmpr#r$r(rNzcmp_to_key..K.__lt__cs|j|jdkSrOrLrPrQr#r$r;rNzcmp_to_key..K.__gt__cs|j|jdkSrOrLrPrQr#r$__eq__rNzcmp_to_key..K.__eq__cs|j|jdkSrOrLrPrQr#r$r5rNzcmp_to_key..K.__le__cs|j|jdkSrOrLrPrQr#r$r@rNzcmp_to_key..K.__ge__N) rrr __slots__rMr(r;rSr5r@__hash__r#rQr#r$Ks     rV)rD)rRrVr#rQr$rsr)rcCsXt|}|tur2rHz#partial.__repr__..css |]\}}|d|VqdS)z=Nr#rEZkvr#r#r$rg3rHZ functoolsz functools.z(, z)) typerrfr[Zextendr\r]itemsrjoin)r*Zqualnamer\r#r#r$__repr__.s  zpartial.__repr__cCs*t||jf|j|j|jpd|jp$dffSr)rkr[r\r]rr*r#r#r$ __reduce__8szpartial.__reduce__cCst|tstdt|dkr0tdt||\}}}}t|rrt|trr|dur`t|trr|durzt|tsztdt|}|duri}nt|turt|}|duri}||_||_||_ ||_ dS)Nz(argument to __setstate__ must be a tupleizexpected 4 items in state, got zinvalid partial state) isinstancetuplerZlenr^Zdictrkrr[r\r])r*Zstater[r\kwdsZ namespacer#r#r$ __setstate__<s4    zpartial.__setstate__) rrrrTr`rdrrnrpruZ __classcell__r#r#rar$r s  r )r c@sBeZdZddZddZddZd dd Zed d Ze e Z dS) r cOsft|s t|ds td|t|trP|j|_|j||_i|j||_n||_||_||_dS)N__get__z${!r} is not callable or a descriptor) r^r_rZformatrqr r[r\r])r*r[r\r]r#r#r$rMbs  zpartialmethod.__init__cCsNdtt|j}ddd|jD}d}|j|jj|jj |j ||dS)Nrjcss|]\}}d||VqdS)z{}={!r}N)rwrhr#r#r$rgwsz)partialmethod.__repr__..z*{module}.{cls}({func}, {args}, {keywords}))ZmodulerGr[r\r]) rmZmaprfr\r]rlrwrbrrr[)r*r\r]Z format_stringr#r#r$rnus  zpartialmethod.__repr__csfdd}j|_|_|S)Ncs,ij|}j|gj|Ri|Srrc)Z cls_or_selfr\r]ror#r$_methodrez3partialmethod._make_unbound_method.._method)__isabstractmethod__Z_partialmethod)r*rxr#ror$_make_unbound_methods z"partialmethod._make_unbound_methodNcCst|jdd}d}|durh|||}||jurht|g|jRi|j}z |j|_WntyfYn0|dur|||}|S)Nrv) rr[r r\r]Z__self__rrzrv)r*rKrGgetresultZnew_funcr#r#r$rvs    zpartialmethod.__get__cCt|jddSNryFrr[ror#r#r$ryz"partialmethod.__isabstractmethod__r) rrrrMrnrzrvpropertyry classmethodr__class_getitem__r#r#r#r$r Zs   r cCst|tr|j}q|Sr)rqr r[r[r#r#r$_unwrap_partials rZ CacheInfo)hitsmissesmaxsizeZcurrsizec@s$eZdZdZefddZddZdS) _HashedSeq hashvaluecCs||dd<|||_dSrr)r*Ztuphashr#r#r$rMs z_HashedSeq.__init__cCs|jSrrror#r#r$rUrNz_HashedSeq.__hash__N)rrrrTrrMrUr#r#r#r$rs rc s|}|r&||7}|D] } || 7}q|rh||fdd|D7}|r||fdd|D7}n$||dkr|d|vr|dSt|S)Nc3|]}|VqdSrr#rErirkr#r$rgrHz_make_key..c3rrr#rrr#r$rgrHr)rlZvaluesr) r\rttypedZkwd_markZ fasttypesrrrkrskeyZitemr#rr$ _make_keys   rFcs~ttrdkrldnTtr\ttr\d}t|t}fdd|_t||Sdurltdfdd}|S)Nrrc dSNrrr#r#rr#r$rHzlru_cache..z=Expected first argument to be an integer, a callable, or Nonecs(t|t}fdd|_t||S)Ncrrr#r#rr#r$rrHz8lru_cache..decorating_function..)_lru_cache_wrapper _CacheInfocache_parametersr) user_functionrrr#r$decorating_functionsz&lru_cache..decorating_function) rqintr^ZboolrrrrrZ)rrrrrr#rr$rs   rcstt d\id djjt gddgdd< dkrh fdd}nN dur fdd}n* fdd} fdd } fd d }||_||_|S) N)rriirFcsd7|i|}|SNrr#)r\rtr|)rrr#r$rsz#_lru_cache_wrapper..wrappercsL||}|}|ur*d7|Sd7|i|}||<|Srr#)r\rtrr|)r cache_getrmake_keyrsentinelrrr#r$r&s  c sp ||} |}|dur|\}}}}||<||< }||< <||< |<d7|WdS d7 Wdn1s0Y|i|} |vrnr } || <|| <|  } } d < <| =| |<n6 }| ||g}||< <|< kWdn1sb0Y|Srr#) r\rtrZlinkZ link_prevZ link_nextZ_keyr|ZlastZoldrootZoldkeyZ oldresult)KEYNEXTPREVRESULTrr cache_lenfullrlockrrrrJrrr#r$r5sB  &  *cs8 WdS1s*0YdSrr#r#)rrrrrrr#r$ cache_infonsz&_lru_cache_wrapper..cache_infocsP8ddgdd<ddWdn1sB0YdS)NrF)clearr#)rrrrrrJr#r$ cache_clearss z'_lru_cache_wrapper..cache_clear)rDrr{Z__len__rrr)rrrrrrrr#)rrrrrrrrrrrrrrrJrrrr$r s* *9 r)rcCstdd|S)N)r)r)rr#r#r$rrrcCsg}dd|D}|s|S|D]2}|d}|D]}||ddvr.d}qq.qRq|durbtd|||D]}|d|krp|d=qpqdS)NcSsg|] }|r|qSr#r#rEZsr#r#r$ rHz_c3_merge..rrzInconsistent hierarchy) RuntimeErrorappend)Z sequencesr|Zs1Z candidateZs2Zseqr#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)rEZb)baser#r$rgsz_c3_mro..cg|]}t|dqSabcs_c3_mrorErrr#r$rrHz_c3_mro..crrrrrr#r$rrHcrrrrrr#r$rrH) Z enumerateZreversedZ __bases__r_rslistrZanyrZremover) rGrZiZboundaryZexplicit_basesZabstract_basesZ other_basesZexplicit_c3_mrosZabstract_c3_mrosZ other_c3_mrosr#)rrr$rsD   rcstjfddfddDfddfddDtg}D]}g}|D]0}|vrht|rh|fdd|jDqh|s||qX|jtd d |D] }|D]}||vr||qqqXt|d S) Ncs|vot|dot|S)N__mro__)r_r)typ)basesrGr#r$ is_relatedsz _compose_mro..is_relatedcsg|]}|r|qSr#r#rEZn)rr#r$rrHz _compose_mro..cs&D]}||kr||jvrdSqdS)NTF)r)rr+)typesr#r$is_strict_basesz$_compose_mro..is_strict_basecsg|]}|s|qSr#r#r)rr#r$rrHcsg|]}|vr|qSr#r#r)type_setr#r$rrHT)rZreverser)ZsetrZ__subclasses__rrZsortrsr)rGrmrorZfoundZsubZsubclsr#)rrGrrrrr$ _compose_mros*    rcCstt||}d}|D]R}|dur\||vrX||jvrX||jvrXt||sXtd||qj||vr|}q||S)NzAmbiguous dispatch: {} or {})rZkeysrrrrwr{)rGregistryrZmatchZtr#r#r$ _find_impls rcsddl}ddl}i|dfddd fdd fdd}t|dd |t<|_|_||_j |_ t |||S) Nrc sxdur"t}|kr"|z |}WnDtyrz |}Wntydt|}Yn0||<Yn0|Sr)rrZKeyErrorr)rGZ current_tokenZimpl) cache_tokendispatch_cacherr#r$dispatch0s    z singledispatch..dispatchcs|durttr fddStdi}|s@tdd}ddlm}tt||\}ttstd|d d |<durt d rt  |S) Ncs |Srr#)Zf)rGregisterr#r$rPrHz2singledispatch..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) rqrkrrZZtypingrrYrWrlr_rr)rGr[ZannrZargname)rrrrrFr$rGs4    z singledispatch..registercs*|std|dj|i|S)Nz( requires at least 1 positional argumentr)rZrb)r\Zkw)rfuncnamer#r$rhs  zsingledispatch..wrapperrzsingledispatch functionr) rweakrefZWeakKeyDictionaryrrDrrZMappingProxyTyperrZ _clear_cacher)r[rrrr#)rrrrrrr$r s !   r c@s4eZdZddZd ddZd ddZedd ZdS) r cCs4t|s t|ds t|dt||_||_dS)Nrvz is not callable or a descriptor)r^r_rZr dispatcherr[r*r[r#r#r$rMs zsingledispatchmethod.__init__NcCs|jj||dS)Nr)rr)r*rGmethodr#r#r$rszsingledispatchmethod.registercs0fdd}j|_j|_t|j|S)Ncs(j|dj}||i|SrO)rrrbrv)r\ZkwargsrrGrKr*r#r$rxsz-singledispatchmethod.__get__.._method)ryrrr[)r*rKrGrxr#rr$rvs  zsingledispatchmethod.__get__cCr}r~rror#r#r$ryrz)singledispatchmethod.__isabstractmethod__rr)rrrrMrrvrryr#r#r#r$r zs   r c@s.eZdZddZddZdddZeeZdS) r cCs ||_d|_|j|_t|_dSr)r[attrnamerrrrr#r#r$rMszcached_property.__init__cCs8|jdur||_n"||jkr4td|jd|ddS)Nz?Cannot assign the same cached_property to two different names (z and z).)rrZ)r*ownerZnamer#r#r$ __set_name__s  zcached_property.__set_name__Nc Cs|dur |S|jdurtdz |j}Wn6ty^dt|jd|jd}t|dYn0||jt}|tur|jv||jt}|tur| |}z|||j<Wn6tydt|jd|jd}t|dYn0Wdn1s0Y|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 ) rrZrrrkrr{ _NOT_FOUNDrr[)r*ZinstancerrZmsgZvalr#r#r$rvsB      .zcached_property.__get__r) rrrrMrrvrrrr#r#r#r$r s r )rFr);Z__all__ZabcrZ collectionsrZreprlibrZ_threadrrrrrrrr,r-r0r2r6r8r9r<r=r>rArBrCrIrrZ _functoolsZ ImportErrorrDrXrr r rrrrrZstrrrrkrsrrrrrrrrr r rr r#r#r#r$Z s                    AJ   .t  -)\(