B #7(u3@sddlZddlZddlZddlZddlZddlZddlZddlZddlZdddddddd d d d d g Z Gddde Z GdddZ e Z GdddZeZeiZGdddZedZedZedZdZdZdZedZGdddeZGdddedZGd ddZGd!d"d"Zeed#d#dd#dd$d%dZ d&d'Z!d(d)Z"dded*d+d,Z#d-d.Z$d/d0Z%d1d2Z&d3d4Z'd5d6Z(d7d8Z)d9d:Z*d;d<Z+d=d>Z,d?d@Z-dAdBZ.dCdDZ/dEdFZ0dGdHZ1dIdJZ2dKdLZ3dddde1de2de2e3e2e3e2e3e2e3dMZ4dNdOZ5dcd#d#d#dPdPdPdQdRdZ6dSdZ7dTdUZ8dVd Z9e:dWdXd Z;dYdZZd]d^Z?d_dd#d#d#dPdPdPd`dad Z@dbd ZAdS)dN dataclassfieldFieldFrozenInstanceErrorInitVarMISSINGfieldsasdictastuplemake_dataclassreplace is_dataclassc@s eZdZdS)rN)__name__ __module__ __qualname__rr./opt/alt/python37/lib/python3.7/dataclasses.pyrsc@seZdZddZdS)_HAS_DEFAULT_FACTORY_CLASScCsdS)Nz r)selfrrr__repr__sz#_HAS_DEFAULT_FACTORY_CLASS.__repr__N)rrrrrrrrrsrc@s eZdZdS) _MISSING_TYPEN)rrrrrrrrsrc@seZdZddZddZdS) _FIELD_BASEcCs ||_dS)N)name)rrrrr__init__sz_FIELD_BASE.__init__cCs|jS)N)r)rrrrrsz_FIELD_BASE.__repr__N)rrrrrrrrrrsr_FIELD_FIELD_CLASSVAR_FIELD_INITVARZ__dataclass_fields__Z__dataclass_params__Z __post_init__z^(?:\s*(\w+)\s*\.)?\s*(\w+)c@seZdZddZdS) _InitVarMetacCs|S)Nr)rparamsrrr __getitem__sz_InitVarMeta.__getitem__N)rrrrrrrrrsrc@s eZdZdS)rN)rrrrrrrrs) metaclassc@s(eZdZdZddZddZddZdS) r) rtypedefaultdefault_factoryreprhashinitcomparemetadata _field_typecCsRd|_d|_||_||_||_||_||_||_|dkrTsz_tuple_str..z,))join)r>rr)r>r _tuple_strKsrAcs"ttfdd}|S)Nc sDt|tf}|krdS|z |}Wd|X|S)Nz...)id_thread get_identadddiscard)rkeyresult) repr_running user_functionrrwrapper^s   z _recursive_repr..wrapper)set functoolswraps)rJrKr)rIrJr_recursive_reprYs rO)globalslocals return_typec Cs|dkr i}d|krt|d<d}|tk r4||d<d}d|}ddd|D}d |d |d |d |}d |}d|d|d|}i} t||| | df|S)NZBUILTINSZ _return_typez->_return_typer: css|]}d|VqdS)z Nr)r<brrr zsz_create_fn..z def r9r-z: z, zdef __create_fn__(z): z return Z __create_fn__)builtinsrr@keysexec) rargsZbodyrPrQrRZreturn_annotationZtxtZ local_varsnsrrr _create_fnls   r\cCs0|rd|d|d|dS|d|d|S)NzBUILTINS.object.__setattr__(r:r-r;=r)r7rvalue self_namerrr _field_assignsr`cCsd|j}|jtk rV|jr@|j||<|d|jd|j}q|j||<|d}n8|jr|jtkrn|j}q|jtk r|j||<|j}ndS|jtkrdSt||j||S)NZ_dflt_z() if z is _HAS_DEFAULT_FACTORY else z())rr#rr&r"r)rr`)r=r7rPr_Z default_namer^rrr _field_inits"         racCsV|jtkr|jtkrd}n&|jtk r2d|j}n|jtk r@d}|jd|j|S)NrSz=_dflt_z=_HAS_DEFAULT_FACTORYz:_type_)r"rr#r)r=r"rrr _init_params  rbc Csd}xB|D]:}|jr |jtkr(|jtks.d}q |r td|jdq Wdd|D}|ttdg}x(|D] }t||||} | rp| | qpW|rd d d |D} | |d t d | d |sdg}t d|gdd|D|||ddS)NFTznon-default argument z follows default argumentcSsi|]}|jd|jqS)Z_type_)r!r)r<r=rrr sz_init_fn..)r_HAS_DEFAULT_FACTORYr:css|]}|jtkr|jVqdS)N)r)rr)r<r=rrrrVsz_init_fn..r;r9r-passrcSsg|]}|jrt|qSr)r&rb)r<r=rrrr?sz_init_fn..)rQrPrR) r&r"rr# TypeErrorrupdaterdraappendr@_POST_INIT_NAMEr\) rr7 has_post_initr_rPZ seen_defaultr=rQZ body_lineslineZ params_strrrr_init_fns6   rlcCs2tdddddd|Ddg|d}t|S) Nr)rz(return self.__class__.__qualname__ + f"(z, cSs g|]}|jd|jdqS)z={self.z!r})r)r<r=rrrr?sz_repr_fn..z)")rP)r\r@rO)rrPfnrrr_repr_fns rncCsp|td}|r,dddd|Dd}nd}tdd d |d d d f||dtddd |d ddf||dfS)N)clsrr9r:css|]}t|jVqdS)N)r$r)r<r=rrrrVsz'_frozen_get_del_attr..z,)z() __setattr__)rrr^z 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))rQrP __delattr__)rrz; raise FrozenInstanceError(f"cannot delete field {name!r}")z"super(cls, self).__delattr__(name))rr@r\)rorrPrQZ fields_strrrr_frozen_get_del_attrs&  rscCs$t|ddd|||dg|dS)N)rotherz%if other.__class__ is self.__class__:z return zreturn NotImplemented)rP)r\)rop self_tuple other_tuplerPrrr_cmp_fn2s rxcCs$td|}tddd|dg|dS)Nr__hash__)rz return hash(r-)rP)rAr\)rrPrvrrr_hash_fn@s   rzcCs$||jkp"t||jko"|j|jkS)N)ClassVarr!Z _GenericAliasZ __origin__)a_typetypingrrr _is_classvarHs r~cCs ||jkS)N)r)r| dataclassesrrr _is_initvarPsrc Cst|}|rd}|d}|s2tj|jj}n2tj|j}|rd|j||krdtj|jj}|r|||d|rdSdS)NTF)_MODULE_IDENTIFIER_REmatchgroupsysmodulesgetr__dict__) Z annotationroZa_moduler|Zis_type_predicaterr[Z module_namemodulerrr_is_typeVs)  rcCs8t||t}t|tr|}nt|tjr,t}t|d}||_||_t |_ t j d}|rt||st|jtrt|j|||jtrt|_ |j t krt j t}t||st|jtrt|j|||jtrt|_ |j ttfkr|jtk rtd|jd|j t kr4t|jtttfr4tdt|jd|jd|S)N)r"r}zfield z cannot have a default factoryzmutable default z for field z$ is not allowed: use default_factory)r/r isinstancerr+MemberDescriptorTyperrr!rr)rrrr~strrr{rrrrrr#rfr"listdictrLr8)roZa_namer|r"r=r}rrrr _get_fields:             rcCs||jkrdSt|||dS)NTF)rsetattr)rorr^rrr_set_new_attributes  rcCsdS)Nr)rorrPrrr_hash_set_nonesrcCsdd|D}t||S)NcSs(g|] }|jdkr|jrn|jr|qS)N)r%r')r<r=rrrr?sz_hash_add..)rz)rorrPfldsrrr _hash_addsrcCstd|jdS)Nz-Cannot overwrite attribute __hash__ in class )rfr)rorrPrrr_hash_exceptionsr))FFFF)FFFT)FFTF)FFTT)FTFF)FTFT)FTTF)FTTT)TFFF)TFFT)TFTF)TFTT)TTFF)TTFT)TTTF)TTTTc si}jtjkr tjjj}ni}ttt||||||d} d} xXjdddD]D} t| t d} | rXd} x| D]} | || j <qzWt| tj rXd} qXWj di}fdd|D}xT|D]L} | || j <tt| j dtr| jtkrt| j qt| j | jqWx<jD].\}}t|tr&||kr&t|dq&W| r| rr|srtd | s|rtd tt |j d t}|tkp|dkod jk }|r|std |rtt}dd| D}tdt|||d|krdnd|dd| D}|rTdd|D}tdt|||rdd|D}td|}td|}td td d|||d|rdd|D}td|}td|}xFdD]>\}}t|t|||||drtd|djdqW|rLx>t||D].}t|j|rtd|jdjqWtt |t |t ||f}|r||||_!tdsjt"t#$%dd _&S)!NFrT__annotations__csg|]\}}t||qSr)r)r<rr!)rorrr?Qsz"_process_class..z& is a field but has no type annotationz5cannot inherit non-frozen dataclass from a frozen onez5cannot inherit frozen dataclass from a non-frozen onery__eq__z eq must be true if order is truecSsg|]}|jttfkr|qSr)r)rr)r<r=rrrr?srrZ__dataclass_self__cSsg|]}|jtkr|qSr)r)r)r<r=rrrr?scSsg|]}|jr|qSr)r$)r<r=rrrr?srcSsg|]}|jr|qSr)r')r<r=rrrr?srtz==)rPcSsg|]}|jr|qSr)r')r<r=rrrr?s))__lt__<)__le__z<=)__gt__>)__ge__z>=zCannot overwrite attribute z in class z). Consider using functools.total_ordering__doc__z -> NonerS)'rrrrr_PARAMSr3__mro__r/_FIELDSvaluesrr7ritemsrrr"rdelattrrfr8hasattrrirrlrnrArxrrs _hash_actionboolryrinspectZ signaturer r)ror&r$r4r5r6r7rrPZany_frozen_baseZhas_dataclass_basesrUZ base_fieldsr=Zcls_annotationsZ cls_fieldsrr^Z class_hashZhas_explicit_hashrjrZ field_listrvrwrurmZ hash_actionr)ror_process_classs                       rF)r&r$r4r5r6r7cs*fdd}|dkr"|S||S)Ncst|S)N)r)ro)r4r7r&r5r$r6rrwrapszdataclass..wrapr)_clsr&r$r4r5r6r7rr)r4r7r&r5r$r6rrscCsByt|t}Wntk r*tdYnXtdd|DS)Nz0must be called with a dataclass type or instancecss|]}|jtkr|VqdS)N)r)r)r<r=rrrrVszfields..)r/rAttributeErrorrftupler)Zclass_or_instancerrrrrs cCstt|tS)N)rr!r)objrrr_is_dataclass_instancesrcCs t|tr|nt|}t|tS)N)rr!rr)rrorrrr s) dict_factorycCst|stdt||S)Nz0asdict() should be called on dataclass instances)rrf _asdict_inner)rrrrrr scst|rHg}x2t|D]&}tt||j}||j|fqW|St|trvt|drvt |fdd|DSt|t tfrt |fdd|DSt|t rt |fdd| DSt |SdS)N_fieldscsg|]}t|qSr)r)r<v)rrrr?Fsz!_asdict_inner..c3s|]}t|VqdS)N)r)r<r)rrrrVKsz _asdict_inner..c3s&|]\}}t|t|fVqdS)N)r)r<kr)rrrrVMs)rrrr/rrhrrrr!rrrcopydeepcopy)rrrHr=r^r)rrr+s r) tuple_factorycCst|stdt||S)Nz1astuple() should be called on dataclass instances)rrf_astuple_inner)rrrrrr Tscst|rBg}x,t|D] }tt||j}||qW|St|trpt|drpt |fdd|DSt|t tfrt |fdd|DSt|t rt |fdd| DSt |SdS)Nrcsg|]}t|qSr)r)r<r)rrrr?zsz"_astuple_inner..c3s|]}t|VqdS)N)r)r<r)rrrrVsz!_astuple_inner..c3s&|]\}}t|t|fVqdS)N)r)r<rr)rrrrVs)rrrr/rrhrrrr!rrrrr)rrrHr=r^r)rrrls rr)bases namespacer&r$r4r5r6r7c sdkrint} i} x|D]} t| tr>| } d}nDt| dkrT| \} }n.t| dkrt| \} }}|| <ntd| t| tr| std| t| rtd| | | krtd| | | || | <q&W| d<t ||ifd d }t ||||||| d S) Nz typing.AnyrzInvalid field: z'Field names must be valid identifiers: z"Field names must not be keywords: zField name duplicated: rcs |S)N)rg)r[)rrrz make_dataclass..)r&r$r4r5r6r7) rrLrrlenrf isidentifierkeyword iskeywordrEr+ new_classr)Zcls_namerrrr&r$r4r5r6r7seenZannsitemrtpspecror)rrr s6           cOst|dkr tdt|d|r,|\}nd|kr@|d}ntdt|sXtdx~t|tD]l}|jtkrxqh|j s|j |krht d|j dqh|j |krh|jt krt d |j d t||j ||j <qhW|j f|S) Nrz*replace() takes 1 positional argument but z were givenrz7replace() missing 1 required positional argument: 'obj'z1replace() should be called on dataclass instanceszfield zC is declared with init=False, it cannot be specified with replace()zInitVar z! must be specified with replace())rrfpoprr/rrr)rr&rr8r __class__)rZZchangesrr=rrrr s*      )N)Brerrr+rrrWrMrC__all__rrrrdrrr,r*rrrrrrricompilerr!rrrr3rrArOr\r`rarbrlrnrsrxrzr~rrrrrrrrrrrrr rr rrr rr r rrrrs  : 62 ;RA )@