o ?Og@s gdZddlmZddlmZddlmZddlmZddl 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.lmZWn e yYnwe!Z"e"fd/d0Z#zdd1lm#Z#Wn e yYnwGd2d3d3Z$zdd4lm$Z$Wn e yYnwGd5d6d6e!Z%d7d8Z&ed9gd:Z'Gd;d<dZ/dWdAdBZ0dCdDZ1zddElm1Z1Wn e y:YnwdFdGZ2dHdIZ3dXdKdLZ4dMdNZ5dOdPZ6dQdRZ7GdSdTdTZ8e!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 Csf |D]}zt||}Wn tyYqwt|||q|D]}t||t||iq||_|SN)getattrAttributeErrorsetattrupdate __wrapped__)wrapperwrappedassignedupdatedattrvaluer'0/opt/alt/python310/lib64/python3.10/functools.pyr#s  rcCs tt|||dS)Nr"r#r$)r rr)r'r'r(rAsrcC, t|||}||ur|S| o||kSrtype__lt__selfotherNotImplemented op_resultr'r'r( _gt_from_ltY r3cC* t|||}||ur|S|p||kSrr+r.r'r'r( _le_from_lt`  r6cC$ t|||}||ur|S| Srr+r.r'r'r( _ge_from_ltg r9cC, t|||}||ur|S| p||kSrr,__le__r.r'r'r( _ge_from_lenr4r>cC* t|||}||ur|S|o||kSrr<r.r'r'r( _lt_from_leur7r@cCr8rr<r.r'r'r( _gt_from_le|r:rAcCr*rr,__gt__r.r'r'r( _lt_from_gtr4rDcCr5rrBr.r'r'r( _ge_from_gtr7rEcCr8rrBr.r'r'r( _le_from_gtr:rFcCr;rr,__ge__r.r'r'r( _le_from_ger4rIcCr?rrGr.r'r'r( _gt_from_ger7rJcCr8rrGr.r'r'r( _lt_from_ger:rKrCr=rHr-)r-r=rCrHcsX fddtD}|stdt|}t|D]\}}||vr)||_t||qS)Ncs(h|]}t|dtt|dur|qSr)robject).0opclsr'r( s(z!total_ordering..z6must define at least one ordering operation: < > <= >=)_convert ValueErrormaxrr)rProotsrootopnameopfuncr'rOr(rs rcs Gfdddt}|S)NcsZeZdZdgZddZfddZfddZfdd Zfd d Zfd d Z dZ dS)zcmp_to_key..KobjcSs ||_dSrrY)r/rYr'r'r(__init__s zcmp_to_key..K.__init__cs|j|jdkSNrrZr/r0mycmpr'r(r-zcmp_to_key..K.__lt__cs|j|jdkSr\rZr]r^r'r(rCr`zcmp_to_key..K.__gt__cs|j|jdkSr\rZr]r^r'r(__eq__r`zcmp_to_key..K.__eq__cs|j|jdkSr\rZr]r^r'r(r=r`zcmp_to_key..K.__le__cs|j|jdkSr\rZr]r^r'r(rHr`zcmp_to_key..K.__ge__N) rrr __slots__r[r-rCrar=rH__hash__r'r^r'r(Ks     rd)rL)r_rdr'r^r(rsr)rcCsT t|}|turzt|}Wntytddw|}|D]}|||}q |S)Nz0reduce() of empty iterable with no initial value)iter_initial_missingnext StopIteration TypeError)ZfunctionZsequenceinitialitr&Zelementr'r'r(r s     r )r csHeZdZ dZfddZddZeddZdd Zd d Z Z S) r )funcargskeywordsr __weakref__cs^t|stdt|dr|j|}i|j|}|j}tt||}||_||_||_|S)Nz#the first argument must be callablerl) callablerihasattrrmrnrlsuperr __new__)rPrlrmrnr/ __class__r'r(rss  zpartial.__new__cOs*i|j|}|jg|j|Ri|Srrnrlrm)r/rmrnr'r'r(__call__+szpartial.__call__cCst|j}t|jg}|dd|jD|dd|jDt|jdkr6d|dd |dS|dd |dS) Ncss|]}t|VqdSr)repr)rMxr'r'r( 3z#partial.__repr__..css"|] \}}|d|VqdS)=Nr'rMkvr'r'r(rz4s functoolsz functools.(, )) r,rrxrlextendrmrnitemsrjoin)r/qualnamermr'r'r(__repr__/s  zpartial.__repr__cCs*t||jf|j|j|jpd|jpdffSr)r,rlrmrnrr/r'r'r( __reduce__9szpartial.__reduce__cCst|ts tdt|dkrtdt||\}}}}t|r9t|tr9|dur0t|tr9|dur=t|ts=tdt|}|durHi}n t|turRt|}|durXi}||_||_||_ ||_ dS)Nz(argument to __setstate__ must be a tuplezexpected 4 items in state, got zinvalid partial state) isinstancetuplerilenrpdictr,rrlrmrn)r/staterlrmkwds namespacer'r'r( __setstate__=s(     zpartial.__setstate__) rrrrbrsrwrrrr __classcell__r'r'rtr(r s   r )r c@sDeZdZ ddZddZddZd dd Zed d Ze e Z dS) r cOsht|st|dstd|t|tr)|j|_|j||_i|j||_dS||_||_||_dS)N__get__z${!r} is not callable or a descriptor) rprqriformatrr rlrmrn)r/rlrmrnr'r'r(r[cs   zpartialmethod.__init__cCsNdtt|j}ddd|jD}d}|j|jj|jj |j ||dS)Nrcss |] \}}d||VqdS)z{}={!r}N)rr}r'r'r(rzxsz)partialmethod.__repr__..z*{module}.{cls}({func}, {args}, {keywords}))modulerPrlrmrn) rmaprxrmrnrrrurrrl)r/rmrn format_stringr'r'r(rvs  zpartialmethod.__repr__csfdd}j|_|_|S)Ncs,ij|}j|gj|Ri|Srrv) cls_or_selfrmrnrr'r(_methodsz3partialmethod._make_unbound_method.._method)__isabstractmethod___partialmethod)r/rr'rr(_make_unbound_methods z"partialmethod._make_unbound_methodNcCst|jdd}d}|dur4|||}||jur4t|g|jRi|j}z|j|_Wn ty3Ynw|dur@|||}|S)Nr) rrlr rmrn__self__rrr)r/rYrPgetresultnew_funcr'r'r(rs    zpartialmethod.__get__cCt|jddSNrFrrlrr'r'r(rz"partialmethod.__isabstractmethod__r) rrrr[rrrpropertyr classmethodr__class_getitem__r'r'r'r(r [s   r cCst|tr |j}t|ts|Sr)rr rlrlr'r'r(_unwrap_partials  r CacheInfo)hitsmissesmaxsizecurrsizec@s&eZdZ dZefddZddZdS) _HashedSeq hashvaluecCs||dd<|||_dSrr)r/tuphashr'r'r(r[s z_HashedSeq.__init__cCs|jSrrrr'r'r(rcsz_HashedSeq.__hash__N)rrrrbrr[rcr'r'r'r(rs   rc s |}|r||7}|D]} || 7}q |r8||fdd|D7}|r4||fdd|D7}t|S||dkrJ|d|vrJ|dSt|S)Nc3|]}|VqdSrr'rMrr,r'r(rzr{z_make_key..c3rrr'rrr'r(rzr{r)rvaluesr) rmrtypedkwd_mark fasttypesrr,rkeyitemr'rr( _make_keys  rFcs ttr dkr dn*tr/ttr/d}t|t}fdd|_t||Sdur7tdfdd}|S)Nrrc dSNrrr'r'rr'r( zlru_cache..z=Expected first argument to be an integer, a callable, or Nonecs(t|t}fdd|_t||S)Ncrrr'r'rr'r(rrz8lru_cache..decorating_function..)_lru_cache_wrapper _CacheInfocache_parametersr) user_functionr!rr'r(decorating_functions z&lru_cache..decorating_function) rintrpboolrrrrri)rrrr!rr'rr(rs    rcstt d\id djjt gddgdd< dkr4 fdd}n' durF fdd}n fdd} fdd } fd d }||_||_|S) N)rrrFcsd7|i|}|SNrr')rmrr)rrr'r(r!sz#_lru_cache_wrapper..wrappercsL||}|}|urd7|Sd7|i|}||<|Srr')rmrrr)r cache_getrmake_keyrsentinelrrr'r(r!'s  c s ||} C|}|dur@|\}}}}||<||< }||< <||< |<d7|WdS d7 Wdn1sNwY|i|} a|vrbnKr } || <|| <|  } } d < <| =| |<n+ }| ||g}||< <|< kWd|SWd|SWd|S1swY|Srr') rmrrlinkZ link_prevZ link_nextZ_keyrZlastZoldrootZoldkeyZ oldresult)KEYNEXTPREVRESULTrr cache_lenfullrlockrrrrVrrr'r(r!6sX       $ $ $$cs: WdS1swYdSrr'r')rrrrrrr'r( cache_infoos$z&_lru_cache_wrapper..cache_infocsT ddgdd<ddWddS1s#wYdS)NrF)clearr')rrrrrrVr'r( cache_clearts"z'_lru_cache_wrapper..cache_clear)rLrr__len__rrr)rrrrr!rrr')rrrrrrrrrrrrrrrVrrrr(r s* *9 r)rcCs tdd|S)N)r)r)rr'r'r(rsrcCs g} dd|D}|s|S|D]}|d}|D]}||ddvr'd}nqnq|dur3td|||D] }|d|krE|d=q:q)NTcSsg|]}|r|qSr'r'rMsr'r'r( sz_c3_merge..rrzInconsistent hierarchy) RuntimeErrorappend) sequencesrs1 candidates2seqr'r'r( _c3_merges.  rNc s tt|jD]\}tdrt|j|}nqd}r#tngt|jd|}g}t|j|d}D]t|rStfdd|jDsS|q;|D] qVfdd|D}fdd|D}fdd|D} t |gg||| |g|g|gS) N__abstractmethods__rc3s|]}t|VqdSr) issubclass)rMb)baser'r(rzs  z_c3_mro..cg|]}t|dqSabcs_c3_mrorMrrr'r(rz_c3_mro..crrrrrr'r(rrcrrrrrr'r(rr) enumeratereversed __bases__rqrlistranyrremover) rPriboundaryexplicit_basesabstract_bases other_basesexplicit_c3_mrosabstract_c3_mros other_c3_mrosr')rrr(rsJ   rcs tjfddfddDfddfddDtg}D]C}g}|D]}|vrMt|rM|fdd|jDq5|sV||q-|jtd d |D]}|D] }||vrn||qcq_q-t|d S) Ncs(|vot|dot|t ot|S)N__mro__)rqrrr)typ)basesrPr'r( is_relateds  z _compose_mro..is_relatedcsg|]}|r|qSr'r'rMn)rr'r(rrz _compose_mro..cs&D]}||kr||jvrdSqdS)NTF)r)rr0)typesr'r(is_strict_bases z$_compose_mro..is_strict_basecsg|]}|s|qSr'r'r )r r'r(rrcsg|]}|vr|qSr'r'r)type_setr'r(rrT)rreverser)setr__subclasses__rrsortrr)rPr mrorfoundsubsubclsr')rrPrr r r r( _compose_mros4      rcCsv t||}d}|D])}|dur/||vr-||jvr-||jvr-t||s-td||n||vr5|}q ||S)NzAmbiguous dispatch: {} or {})rkeysrrrrr)rPregistryrmatchtr'r'r( _find_impls"   rcs ddl}ddl}i|dfddddd fdd fdd }t|d d |t<|_|_||_j |_ t |||S) Nrc sz durt}|kr|z|}W|Sty<z|}Wnty4t|}Ynw||<Y|Swr)rrKeyErrorr)rP current_tokenimpl) cache_tokendispatch_cacherr'r(dispatch2s$     z singledispatch..dispatchcSst|to t|t Sr)rr,rrOr'r'r(_is_valid_dispatch_typeIsz/singledispatch.._is_valid_dispatch_typecs r|durfddSn?|durtddtdi}|s-tdd}dd lm}tt||\}sPtd |d d|<dur`td r`t |S) Ncs |Srr')f)rPregisterr'r(rUrz2singledispatch..register..z(Invalid first argument to `register()`. z is not a class.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. r) rirtypingr%rgrerrqrr)rPrlannr%argname)r"rr r$rrOr(r$Ls<   z singledispatch..registercs*|s td|dj|i|S)Nz( requires at least 1 positional argumentr)riru)rmkw)r!funcnamer'r(r!tszsingledispatch..wrapperrzsingledispatch functionr) r weakrefWeakKeyDictionaryrrLr$r!MappingProxyTyperr _clear_cacher)rlr r+r!r')r"rr!r r*r$rr(r s" (   r c@s6eZdZ ddZd ddZd ddZedd ZdS) r cCs4t|st|dst|dt||_||_dS)Nrz is not callable or a descriptor)rprqrir dispatcherrlr/rlr'r'r(r[s  zsingledispatchmethod.__init__NcCs |jj||dS)Nr)r/r$)r/rPmethodr'r'r(r$szsingledispatchmethod.registercs0fdd}j|_j|_t|j|S)Ncs(j|dj}||i|Sr\)r/r!rur)rmkwargsr1rPrYr/r'r(rsz-singledispatchmethod.__get__.._method)rr$rrl)r/rYrPrr'r3r(rs  zsingledispatchmethod.__get__cCrrrrr'r'r(rrz)singledispatchmethod.__isabstractmethod__r)rrrr[r$rrrr'r'r'r(r s   r c@s.eZdZddZddZdddZeeZdS) rcCs ||_d|_|j|_t|_dSr)rlattrnamerrrr0r'r'r(r[s zcached_property.__init__cCs:|jdur ||_dS||jkrtd|jd|ddS)Nz?Cannot assign the same cached_property to two different names (z and z).)r4ri)r/ownernamer'r'r( __set_name__s   zcached_property.__set_name__Nc Cs|dur|S|jdurtdz|j}Wnty-dt|jd|jd}t|dw||jt}|tur|jB||jt}|turn| |}z|||j<Wn!tymdt|jd|jd}t|dwWd|SWd|S1swY|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 ) r4rirrr,rr _NOT_FOUNDrrl)r/instancer5rmsgvalr'r'r(rsL            zcached_property.__get__r) rrrr[r7rrrrr'r'r'r(rs  r)rFr);__all__abcr collectionsrreprlibr_threadrr rrrrrr1r3r6r9r>r@rArDrErFrIrJrKrRrr _functools ImportErrorrLrfr r r rrrrrstrrr,rrrrrrrrrr r r8rr'r'r'r(s                       A J  .t -*f(