Vc ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlm Z m Z gdZ GddeZGddZeZGdd ZeZGd d ZeZejiZGd d ZedZedZedZdZdZdZejdZ GddZ!GddZ"GddZ#eedddddeddZ$dZ%dZ&d Z'dded!d"Z(d#Z)d$Z*d%Z+d&Z,d'Z-d(Z.d)Z/d*Z0d+Z1d,Z2d-Z3d.Z4d/Z5d0Z6d1Z7d2Z8d3Z9d4Z:id5dd6dd7dd8dd9e8d:dd;e9de:d?e9d@e:dAe9dBe:dCe9dDe:Z;dEZdHZ?dIZ@dZddddJdJdJddJdJdJdK dLZAdMZBdNZCdOZDeEdPdQZFdRZGeHdSdTZIdUZJdVdddddJdJdJddJdJdJdW dXZKdYZLdS)[N) FunctionType GenericAlias) dataclassfieldFieldFrozenInstanceErrorInitVarKW_ONLYMISSINGfieldsasdictastuplemake_dataclassreplace is_dataclassceZdZdS)rN__name__ __module__ __qualname__$/usr/lib64/python3.11/dataclasses.pyrrsrrceZdZdZdS)_HAS_DEFAULT_FACTORY_CLASScdS)Nz rselfs r__repr__z#_HAS_DEFAULT_FACTORY_CLASS.__repr__s{rN)rrrrrrrrrs#rrceZdZdS) _MISSING_TYPENrrrrr!r!Drr!ceZdZdS) _KW_ONLY_TYPENrrrrr$r$r"rr$ceZdZdZdZdS) _FIELD_BASEc||_dSNnamerr*s r__init__z_FIELD_BASE.__init__  rc|jSr(r)rs rrz_FIELD_BASE.__repr__s yrN)rrrr,rrrrr&r&s2rr&_FIELD_FIELD_CLASSVAR_FIELD_INITVAR__dataclass_fields____dataclass_params__ __post_init__z^(?:\s*(\w+)\s*\.)?\s*(\w+)c$eZdZdZdZdZdZdS)r typec||_dSr(r6)rr7s rr,zInitVar.__init__r-rct|jtr |jj}nt|j}d|dS)Nzdataclasses.InitVar[]) isinstancer7rrepr)r type_names rrzInitVar.__repr__sB di & & ( *IITYI2i2222rc t|Sr()r )clsr7s r__class_getitem__zInitVar.__class_getitem__st}}rN)rrr __slots__r,rr@rrrr r sFI333rr c:eZdZdZdZdZdZeeZ dS)r) r*r7defaultdefault_factoryr<hashinitcomparemetadatakw_only _field_typec d|_d|_||_||_||_||_||_||_|tntj ||_ ||_ d|_ dSr()r*r7rCrDrFr<rErG_EMPTY_METADATAtypesMappingProxyTyperHrIrJ) rrCrDrFr<rErGrHrIs rr,zField.__init__ ss   .    $:/99  rcd|jd|jd|jd|jd|jd|jd|jd|jd |jd |j d |j d S) Nz Field(name=z,type=z ,default=z,default_factory=z,init=,repr=z,hash=z ,compare=z ,metadata=z ,kw_only=z ,_field_type=)) r*r7rCrDrFr<rErGrHrIrJrs rrzField.__repr__s        <  $(#7            <  !M   <   $/    rcxtt|jdd}|r||j||dSdS)N __set_name__)getattrr7rC)rownerr*funcs rrSzField.__set_name__2sMtDL))>4@@  , Dud + + + + + , ,rN) rrrrAr,rrS classmethodrr@rrrrrsV I     .,,,$ L11rrceZdZdZdZdZdS)_DataclassParamsrFr<eqorder unsafe_hashfrozencZ||_||_||_||_||_||_dSr(rZ)rrFr<r[r\r]r^s rr,z_DataclassParams.__init__Es1   & rc hd|jd|jd|jd|jd|jd|jd S)Nz_DataclassParams(init=rPz,eq=z,order=z ,unsafe_hash=z,frozen=rQrZrs rrz_DataclassParams.__repr__Mst  g  $/  +  rN)rrrrAr,rrrrrYrY<s9IrrYTrCrDrFr<rErGrHrIc p|tur|turtdt||||||||S)aReturn an object to identify dataclass fields. default is the default value of the field. default_factory is a 0-argument function called to initialize a field's value. If init is true, the field will be a parameter to the class's __init__() function. If repr is true, the field will be included in the object's repr(). If hash is true, the field will be included in the object's hash(). If compare is true, the field will be used in comparison functions. metadata, if specified, must be a mapping which is stored but not otherwise examined by dataclass. If kw_only is true, the field will become a keyword-only parameter to __init__(). It is an error to specify both default and default_factory. z/cannot specify both default and default_factory)r ValueErrorrras rrr[sQ$gL/"@LJKKK /4tW7 $ $$rcftd|Dtd|DfS)Nc36K|]}|j |j|VdSr(rFrI.0fs r z(_fields_in_init_order..ws0@@qv@ai@!@@@@@@rc36K|]}|j |j|VdSr(rfrgs rrjz(_fields_in_init_order..xs0<<qvz_tuple_str..s)@@@AH//qv//@@@r,))join)rur s` r _tuple_strry|sD t Esxx@@@@@@@AA E E EErcfttjfd}|S)Nct|tjf}|vrdS| |}|n#|wxYw|S)Nz...)id_thread get_identadddiscard)rkeyresult repr_running user_functions rwrapperz _recursive_repr..wrappershh)+++ ,  5 &"]4((F   % % % %L  % % % % s A!!A8)set functoolswraps)rrrs` @r_recursive_reprrsI55L_]##     $#  Nr)globalslocals return_typect|i}d|vr t|d<d}|tur||d<d}d|}dd|D}d|d |d |d |}d |}d |d|d|}i} t ||| | ddi|S)NBUILTINS _return_typez->_return_typerr c3 K|] }d|V dS)z Nr)rhbs rrjz_create_fn..s(,,!X!XX,,,,,,rz def rqrQz: , zdef __create_fn__(z): z return __create_fn__r)builtinsr rxkeysexec) r*argsbodyrrrreturn_annotationtxt local_varsnss r _create_fnrs  &%z'!-!,~, 88D>>D 99,,t,,, , ,D =$ < < < < 1 < z_init_fn..&s' 8 8 8Aqv 8 8 8r)r _HAS_DEFAULT_FACTORYrrc3@K|]}|jtu|jVdSr()rJr1r*rgs rrjz_init_fn..6sLBB!".!@BafBBBBBBrrtrqrQpassc,g|]}t|Srrrgs rrvz_init_fn..>s777qKNN777r*c,g|]}t|Srrrgs rrvz_init_fn..Ds@@@AQ@@@rr,)rrr) rFrCr rD TypeErrorr*updaterrappendrx_POST_INIT_NAMEr)r std_fieldskw_only_fieldsr^ has_post_initrrr seen_defaultrir body_linesline params_str _init_paramss r_init_fnrsL << 6 <I( '-I <#  <!;!;!;!;<<<9 8 8 8 8F MM 4 J $$1ffi??  $   d # # #JXXBBfBBBBB YHHHH:HHHIII X 77J777LA  @@@@@@ j kL0 #%"&  ( ( ((rc tddddd|Dzdzg|}t|S)Nrrz(return self.__class__.__qualname__ + f"(rc2g|]}|jd|jdS)z={self.z!r}r)rgs rrvz_repr_fn..Qs= 1 1 1$%$%6 ? ?16 ? ? ? 1 1 1rz)"r)rrxr)r rfns r_repr_fnrMst J?YY 1 1)/ 1 1 1222%  & & &B 2  rc|td}|r&ddd|Dzdz}nd}tddd |d d d f|| tddd |d ddf|| fS)N)r?rrqrrc3>K|]}t|jVdSr()r<r*rgs rrjz'_frozen_get_del_attr..\s*#A#AQDLL#A#A#A#A#A#Arrwrp __setattr__)rr*rz if type(self) is cls or name in :z> raise FrozenInstanceError(f"cannot assign to field {name!r}")z)super(cls, self).__setattr__(name, value))rr __delattr__r+z; raise FrozenInstanceError(f"cannot delete field {name!r}")z"super(cls, self).__delattr__(name))rrxr)r?r rr fields_strs r_frozen_get_del_attrrXs%8::F 388#A#A&#A#A#AAAADH  }/G*GGGXCE%&  ( ( ( }&G*GGGU<>%&  ( ( ( rc <t|ddd|||dg|S)N)rotherz%if other.__class__ is self.__class__:z return zreturn NotImplementedr)r)r*op self_tuple other_tuplers r_cmp_fnrqsE d'??*?b?+??/1&  ' ' ''rcRtd|}tddd|dg|S)Nr__hash__rz return hash(rQr)ryr)r rrs r_hash_fnrsAFF++J j3j3334% ' ' ''rc\||jup#t||juo |j|juSr()ClassVarr7 _GenericAlias __origin__)a_typetypings r _is_classvarrs; fo % :V  449%8;rc@||jupt||juSr()r r7r dataclassess r _is_initvarrs* k) ) 3F||{224rc||juSr()r rs r _is_kw_onlyrs [( ((rct|}|rd}|d}|s*tj|jj}nktj|j}|rE|j||ur)tj|jj}|r4|||d|rdSdS)NTF)_MODULE_IDENTIFIER_REmatchgroupsysmodulesgetr__dict__) annotationr?a_moduleris_type_predicaterr module_namemodules r_is_typersR " ' ' 3 3E  kk!nn  A009BB[__S^44F A&/--k::hF A[__V%677@  ##BFF5;;q>>$:$:HEE 4 5rct||t}t|tr|}n1t|tjrt}t |}||_||_t|_ tj d}|rXt||s|jjj-t;dt|jd|jd|S) N)rCrfield z cannot have a default factoryz$ is a ClassVar but specifies kw_onlyzmutable default z for field z$ is not allowed: use default_factory)rTr r;rrMMemberDescriptorTyperr*r7r/rJrrrrstrrrr0rrr r1rDrrIrC __class__rrc)r?a_namerdefault_kw_onlyrCrirrs r _get_fieldrsyc67++G'5!!#  gu9 : : G ' " " "AF AF AM [__X & &F ,  ( ( ,163'' ,QVS&&/)++ ,,AM }+k(+  , , +163'' +QVS+{7J(** ++AM }.99/ G + /.QV...// / }00 ' 9  ('AI 9G # '&QV&&&'' '  }J19#6#?JIDOOIIFIIIJJ J Hrc\t|tr|jd|j|_|S)Nrt)r;rrr)r?rs r _set_qualnamer5s7%&&D # 0CC5>CC Lrc^||jvrdSt||t|||dS)NTF)rrsetattr)r?r*rs r_set_new_attributer<s? s|t#u Cu 5rcdSr(rr?r rs r_hash_set_nonerKs 4rcVd|D}t|t||S)Nc>g|]}|j|jn|j|Sr()rErGrgs rrvz_hash_add..Os0 K K K!qv K!) K K16 KA K K Kr)rr)r?r rfldss r _hash_addr Ns/ K Kv K K KD htW55 6 66rc0td|j)Nz-Cannot overwrite attribute __hash__ in class )rrrs r_hash_exceptionr Rs( / # // 0 00r)FFFF)FFFT)FFTF)FFTT)FTFF)FTFT)FTTF)FTTT)TFFF)TFFT)TFTF)TFTT)TTFF)TTFT)TTTF)TTTTc j i} |jtjvrtj|jj} ni} t |t t ||||||d} d}|jdddD]Y}t|td}|?d}| D] }|| |j < t|t j rd} Z|j di}g}d}tjt}|D]\}}t!||s2t#|t$r6t'||||jt r|rt+|dd}d}`|t/|||||D]t}|| |j <t#t||j dt0r?|jt4urt7||j Yt ||j |ju|jD]0\}}t#|t0r||vrt+|d1|r&| r|st+d| s|rt+d t |t| |j d t4}|t4up |duod |jv }|r|st9d d | D}t;|\}}|r@t=|t>}tA|dtC|||||d| vrdnd| | d| D}|r+d|D} tA|dtE| | |rOd|D} tGd| }!tGd| }"tA|d tId d|!|"| |rrd|D} tGd| }!tGd| }"dD]C\}}#tA||tI||#|!|"| rt+d|d|jdD|rItK||| D]7}$tA||$j|$rt+d|$jd|j8tLtO|tO|tO||f}%|%r|%||| |_(t|dsB|jt%tSj*|+ddz|_,|r(tA|d t[d!|D| r| st+d"| rt]||| }t_j0||S)#NFrT__annotations__z3 is KW_ONLY, but KW_ONLY has already been specifiedz& is a field but has no type annotationz5cannot inherit non-frozen dataclass from a frozen onez5cannot inherit frozen dataclass from a non-frozen oner__eq__z eq must be true if order is truec<g|]}|jttfv|Sr)rJr/r1rgs rrvz"_process_class..s?EEEQ-FN+CCEqEEErr,r__dataclass_self__c.g|]}|jtu|SrrJr/rgs rrvz"_process_class..s$HHH 0GH!HHHrc g|] }|j | Sr)r<rgs rrvz"_process_class..s000a0000rrc g|] }|j | SrrGrgs rrvz"_process_class..333a3333rrz==rc g|] }|j | Srrrgs rrvz"_process_class..'rr))__lt__<)__le__z<=)__gt__>)__ge__z>=zCannot overwrite attribute z in class z). Consider using functools.total_ordering__doc__z -> Noner__match_args__c3$K|] }|jV dSr(r)rgs rrjz!_process_class..Ns$ A AA A A A A A Arz'weakref_slot is True but slots is False)1rrrrr_PARAMSrY__mro__rT_FIELDSvaluesr*r^rritemsrr;rrr rrrrrCr delattrrcrnhasattrrrrrryrr _hash_actionboolrinspect signaturerrrl _add_slotsabcupdate_abstractmethods)&r?rFr<r[r\r]r^ match_argsrIr weakref_slotr rany_frozen_basehas_dataclass_basesr base_fieldsricls_annotations cls_fields KW_ONLY_seenrr*r7r class_hashhas_explicit_hashall_init_fieldsstd_init_fieldskw_only_init_fieldsr field_listrrrrr hash_actions& r_process_classr?usc F ~$+cn-6 C*4r5+6@@AAAO [Ab ! ' 'a$//  '"&  '')) # #!"qvq'"") '"&l&&'8"==O JL+h'K%++--DD d k * * D4%% DT3 [5H(** D  >4!=!=!=>>>LGG   jdD'BB C C C C 00qv gc16400% 8 8 0yG# 0QV$$$$QVQY///|))++OO e eU # # ODO,C OtMMMNN N .  *6 *)** * .6 .-.. .  C&!!!!!*g66J'72O(D0MX5MP  =R=;<<< EE&--//EEEO2/BB_ _55 3 #O$3$7$*$1=Cf.`s% 8 8 8aGD!& ! ! 8 8 8rrmrs`r_dataclass_getstaterB_s# 8 8 8 86$<< 8 8 88rctt||D]&\}}t||j|'dSr()zipr objectrr*)rstaterrs r_dataclass_setstaterGcsLF4LL%0044 u4U333344rc#K|jdxdSxtdx \}|VdS}t|ds |Ed{VdS t d|jd)NrAr__next__z Slots of 'z' cannot be determined)rrrr(rr)r?slotiterables r _get_slotsrLis ,  ; ' ' TT F SYYYYYJJJJJWXz::X          MMMMNN Nrc d|jvrt|jdt|j}t dt |D}t tj tt|j dd}t tj |jtj||rdnd|d<|D]}||d|ddt!|d d}t#||j|j|}|||_|rt(|_t,|_|S) NrAz already specifies __slots__c3$K|] }|jV dSr(r)rgs rrjz_add_slots..s$441444444rrr ) __weakref__rrr)rrrdictrlr r itertoolschain from_iterablemaprLr# filterfalse __contains__poprTr7 __bases__rrB __getstate__rG __setstate__)r? is_frozenr1cls_dict field_namesinherited_slots field_namequalnames rr-r-ws cl"G3<EEEFFFCL!!H44s 44444K%%c*ck!B$6G&H&HIIO "  ( OE--2      H["''   Z&&&& LLT"""sND11H $s))CL#- : :C$#/.. JrF rFr<r[r\r]r^r0rIrr1c P   f d} || S| |S)aAdd dunder methods based on the fields defined in the class. Examines PEP 526 __annotations__ to determine fields. If init is true, an __init__() method is added to the class. If repr is true, a __repr__() method is added. If order is true, rich comparison dunder methods are added. If unsafe_hash is true, a __hash__() method is added. If frozen is true, fields may not be assigned to after instance creation. If match_args is true, the __match_args__ tuple is added. If kw_only is true, then by default all fields are keyword-only. If slots is true, a new class with a __slots__ attribute is returned. c 6 t|  Sr()r?) r?r[r^rFrIr0r\r<rr]r1s rwrapzdataclass..wraps-c4r5+$j'5*,, ,rr) r?rFr<r[r\r]r^r0rIrr1rds `````````` rrrsq",,,,,,,,,,,,,,    499rc t|t}n#t$rtdwxYwt d|DS)zReturn a tuple describing the fields of this dataclass. Accepts a dataclass or an instance of one. Tuple elements are of type Field. z0must be called with a dataclass type or instancec36K|]}|jtu|VdSr(rrgs rrjzfields..s.GGqq}/FGGGGGGGr)rTr$AttributeErrorrrlr%)class_or_instancer s rr r soL*G44 LLLJKKKL GGFMMOOGGG G GGs2cFtt|tS)z2Returns True if obj is an instance of a dataclass.)r(r7r$)objs r_is_dataclass_instancerks 499g & &&rcxt|tr|nt|}t|tS)zEReturns True if obj is a dataclass or an instance of a dataclass.)r;r7r(r$)rjr?s rrrs2C&& 5##DIIC 3  r) dict_factoryc^t|stdt||S)aReturn the fields of a dataclass instance as a new dictionary mapping field names to field values. Example usage:: @dataclass class C: x: int y: int c = C(1, 2) assert asdict(c) == {'x': 1, 'y': 2} If given, 'dict_factory' will be used instead of built-in dict. The function applies recursively to field values that are dataclass instances. This will also look into built-in containers: tuples, lists, and dicts. z0asdict() should be called on dataclass instances)rkr _asdict_inner)rjrms rr r s4& "# & &LJKKK l + ++rct|r^g}t|D]A}tt||j}||j|fB|St |tr.t|drt|fd|DSt |ttfr$t|fd|DSt |tr6t|fd| DStj|S)N_fieldsc0g|]}t|Srrorhvrms rrvz!_asdict_inner..s#GGGa=L99GGGrc38K|]}t|VdSr(rsrts rrjz _asdict_inner..s-EEAq,77EEEEEErc3^K|]'\}}t|t|fV(dSr(rs)rhkrurms rrjz _asdict_inner.. sW22!Q(<88'<88:222222r)rkr rorTr*rr;rlr(r7listrPr&copydeepcopy)rjrmrrirs ` rrorosoc""%" + +A!'#qv"6"6 EEE MM165/ * * * *|F### C  "GC$;$;"(tCyyGGGG3GGGHH C$ ' ' "tCyyEEEEEEEEEE C  "tCyy2222%(YY[[22222 2}S!!!r) tuple_factoryc^t|stdt||S)aReturn the fields of a dataclass instance as a new tuple of field values. Example usage:: @dataclass class C: x: int y: int c = C(1, 2) assert astuple(c) == (1, 2) If given, 'tuple_factory' will be used instead of built-in tuple. The function applies recursively to field values that are dataclass instances. This will also look into built-in containers: tuples, lists, and dicts. z1astuple() should be called on dataclass instances)rkr_astuple_inner)rjr|s rrr's4& "# & &MKLLL #} - --rct|rWg}t|D]:}tt||j}||;|St |tr.t|drt|fd|DSt |ttfr$t|fd|DSt |tr6t|fd| DStj|S)Nrqc0g|]}t|Srr~rhrur|s rrvz"_astuple_inner..Ms#III>!];;IIIrc38K|]}t|VdSr(rrs rrjz!_astuple_inner..Rs-GGa=99GGGGGGrc3^K|]'\}}t|t|fV(dSr(r)rhrxrur|s rrjz!_astuple_inner..TsT33"a)M::N1m<\<\]333333r)rkr r~rTr*rr;rlr(r7ryrPr&rzr{)rjr|rrirs ` rr~r~?sic""" ! !A"73#7#7GGE MM% }V$$$ C  "GC$;$;"tCyyIIIISIIIJJ C$ ' ' "tCyyGGGG3GGGGGG C  "tCyy3333&)iikk33333 3}S!!!rr) bases namespacerFr<r[r\r]r^r0rIrr1c it}ii|D]}t|tr|}d}nJt|dkr|\}}n1t|dkr |\}}}||<nt d|t|tr|st d|t j|rt d|||vrt d|||||<fd }tj ||i|}t||||||| | | | | S) aReturn a new dynamically created dataclass. The dataclass name will be 'cls_name'. 'fields' is an iterable of either (name), (name, type) or (name, type, Field) objects. If type is omitted, use the string 'typing.Any'. Field objects are created by the equivalent of calling 'field(name, type [, Field-info])'.:: C = make_dataclass('C', ['x', ('y', int), ('z', int, field(init=False))], bases=(Base,)) is equivalent to:: @dataclass class C(Base): x: 'typing.Any' y: int z: int = field(init=False) For the bases and namespace parameters, see the builtin type() function. The parameters init, repr, eq, order, unsafe_hash, and frozen are passed to dataclass(). Nz typing.AnyrzInvalid field: z'Field names must be valid identifiers: z"Field names must not be keywords: zField name duplicated: cf|||d<dS)Nr)r)r annotationsdefaultsrs rexec_body_callbackz*make_dataclass..exec_body_callbacks8 ) ( + rra) rr;rlenr isidentifierkeyword iskeywordrrM new_classr)cls_namer rrrFr<r[r\r]r^r0rIrr1seenitemr*tpspecrr?rrs ` @@rrrZs6  55DKH dC 8DBB YY!^ 8ID"" YY!^ 8!ND"d!HTNN6d6677 7$$$ PD,=,=,?,? PNdNNOO O  T " " KIIIJJ J 4< @>d>>?? ?  D,,,,,,, /(E2/A B BC St$2U!,V *G5". 0 0 00rc t|stdt|tD]}|jt ur|js"|j|vrtd|jd:|j|vrQ|jtur&|j turtd|jdt||j||j<|j di|S)a+Return a new object replacing specified fields with new values. This is especially useful for frozen classes. Example usage:: @dataclass(frozen=True) class C: x: int y: int c = C(1, 2) c1 = replace(c, x=3) assert c1.x == 3 and c1.y == 2 z1replace() should be called on dataclass instancesrzC is declared with init=False, it cannot be specified with replace()zInitVar z! must be specified with replace()r)rkrrTr$r%rJr0rFr*rcr1rCr r)rjchangesris rrrs6$ "# & &MKLLL S' " " ) ) + +33 =O +  v v  . "-!&"-"-"-...  6  3}. E193G E "DAF"D"D"DEEE%c1622GAFO 3= # #7 # ##rr()MrerrzrMr+rrrrQr.r}rr__all__rgrrrr!r r$r rNrLr&r/r0r1r$r"rcompilerr rrYrrnryrrrrrrrrrrrrrrrrrrr r r)r?rBrGrLr-rr rkrrPr rorlrr~rrrrrrs!  ,,,,,,,,   |0////./// 2133        -//        -//)%(,, X  +/00-.. ! !" # #ABB6<2<2<2<2<2<2<2<2~>gDtTD'$$$$$0 F F F&-1")))))4 ) ) )9;9;9;x///&8(8(8(v2 ' ' '''';;;444 )))888v_ _ _ B777000,d,d,d-d-n  -d  -i -d-i-o-i-o-i-o-i-o *cccT999444 O O O///d4dt5$5u>HHH$''' !!!!%,,,,,0&"&"&"R#(.....0"""6/1DtUD%u %G0G0G0G0G0T0$0$0$0$0$r