????
Your IP : 3.21.34.214
B
� fp��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZdddddddd d
ddd
gZ Gdd�de
�ZGdd�d�Ze�Z
Gdd�d�Ze�Ze�i�ZGdd�d�Zed�Zed�Zed�ZdZdZdZe�d�ZGdd�de�ZGdd�ded�ZGd d�d�ZGd!d"�d"�Zeed#d#dd#dd$�d%d�Z d&d'�Z!d(d)�Z"dded*�d+d,�Z#d-d.�Z$d/d0�Z%d1d2�Z&d3d4�Z'd5d6�Z(d7d8�Z)d9d:�Z*d;d<�Z+d=d>�Z,d?d@�Z-dAdB�Z.dCdD�Z/dEdF�Z0dGdH�Z1dIdJ�Z2dKdL�Z3dddde1de2de2e3e2e3e2e3e2e3dM�Z4dNdO�Z5dcd#d#d#dPdPdPdQ�dRd�Z6dSd�Z7dTdU�Z8dVd
�Z9e:dW�dXd �Z;dYdZ�Z<e=d[�d\d
�Z>d]d^�Z?d_dd#d#d#dPdPdPd`�dad�Z@dbd�ZAdS)d�N� dataclass�field�Field�FrozenInstanceError�InitVar�MISSING�fields�asdict�astuple�make_dataclass�replace�is_dataclassc@seZdZdS)rN)�__name__�
__module__�__qualname__�rr�0/opt/alt/python37/lib64/python3.7/dataclasses.pyr�sc@seZdZdd�ZdS)�_HAS_DEFAULT_FACTORY_CLASScCsdS)Nz <factory>r)�selfrrr�__repr__�sz#_HAS_DEFAULT_FACTORY_CLASS.__repr__N)rrrrrrrrr�src@seZdZdS)�
_MISSING_TYPEN)rrrrrrrr�src@seZdZdd�Zdd�ZdS)�_FIELD_BASEcCs
||_dS)N)�name)rrrrr�__init__�sz_FIELD_BASE.__init__cCs|jS)N)r)rrrrr�sz_FIELD_BASE.__repr__N)rrrrrrrrrr�sr�_FIELD�_FIELD_CLASSVAR�_FIELD_INITVARZ__dataclass_fields__Z__dataclass_params__Z
__post_init__z^(?:\s*(\w+)\s*\.)?\s*(\w+)c@seZdZdd�ZdS)�_InitVarMetacCs|S)Nr)rZparamsrrr�__getitem__�sz_InitVarMeta.__getitem__N)rrrrrrrrr�src@seZdZdS)rN)rrrrrrrr�s)� metaclassc@s(eZdZdZdd�Zdd�Zdd�ZdS) r)
r�type�default�default_factory�repr�hash�init�compare�metadata�_field_typecCsRd|_d|_||_||_||_||_||_||_|dkr<tnt �
|�|_d|_dS)N)
rr r!r"r%r#r$r&�_EMPTY_METADATA�types�MappingProxyTyper'r()rr!r"r%r#r$r&r'rrrr�szField.__init__cCsVd|j�d|j�d|j�d|j�d|j�d|j�d|j�d|j�d |j�d
|j �d�S)NzField(name=z,type=z ,default=z,default_factory=z,init=z,repr=z,hash=z ,compare=z
,metadata=z
,_field_type=�))
rr r!r"r%r#r$r&r'r()rrrrr�szField.__repr__cCs(tt|j�dd�}|r$||j||�dS)N�__set_name__)�getattrr r!)r�ownerr�funcrrrr-szField.__set_name__N)rrr� __slots__rrr-rrrrr�sc@s eZdZdZdd�Zdd�ZdS)�_DataclassParams)r%r#�eq�order�unsafe_hash�frozencCs(||_||_||_||_||_||_dS)N)r%r#r3r4r5r6)rr%r#r3r4r5r6rrrrsz_DataclassParams.__init__c
Cs6d|j�d|j�d|j�d|j�d|j�d|j�d�
S)Nz_DataclassParams(init=z,repr=z,eq=z,order=z
,unsafe_hash=z,frozen=r,)r%r#r3r4r5r6)rrrrr'sz_DataclassParams.__repr__N)rrrr1rrrrrrr2sr2T)r!r"r%r#r$r&r'cCs,|tk r|tk rtd��t|||||||�S)a�Return 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.
It is an error to specify both default and default_factory.
z/cannot specify both default and default_factory)r�
ValueErrorr)r!r"r%r#r$r&r'rrrr5scs(|sdSdd��fdd�|D���d�S)Nz()�(�,csg|]}��d|j���qS)�.)r)�.0�f)�obj_namerr�
<listcomp>Tsz_tuple_str.<locals>.<listcomp>z,))�join)r=rr)r=r�
_tuple_strKsr@cs"t��t�����fdd��}|S)Nc sDt|�t��f}|�krdS��|�z�|�}Wd��|�X|S)Nz...)�id�_thread� get_ident�add�discard)r�key�result)�repr_running�
user_functionrr�wrapper^s
z _recursive_repr.<locals>.wrapper)�set� functools�wraps)rIrJr)rHrIr�_recursive_reprYsrN)�globals�locals�return_typec
Cs�|dkri}d|krt|d<d}|tk r4||d<d}d�|�}d�dd�|D��}d |�d
|�d|�d|��}d
�|���}d|�d|�d|��}i} t||| �| df|�S)NZBUILTINS�Z_return_typez->_return_typer9�
css|]}d|��VqdS)z Nr)r;�brrr� <genexpr>zsz_create_fn.<locals>.<genexpr>z def r8r,z:
z, zdef __create_fn__(z):
z
return Z
__create_fn__)�builtinsrr?�keys�exec)
r�argsZbodyrOrPrQZreturn_annotationZtxtZ
local_vars�nsrrr�
_create_fnls
r[cCs0|rd|�d|�d|�d�S|�d|�d|��S)NzBUILTINS.object.__setattr__(r9r,r:�=r)r6r�value� self_namerrr�
_field_assign�sr_cCs�d|j��}|jtk rV|jr@|j||<|�d|j�d|j��}q�|j||<|�d�}n8|jr�|jtkrn|j}q�|jtk r�|j||<|j}ndS|jtkr�dSt||j||�S)NZ_dflt_z() if z is _HAS_DEFAULT_FACTORY else z())rr"rr%r!r(rr_)r<r6rOr^Zdefault_namer]rrr�_field_init�s"
r`cCsV|jtkr|jtkrd}n&|jtk r2d|j��}n|jtk r@d}|j�d|j�|��S)NrRz=_dflt_z=_HAS_DEFAULT_FACTORYz:_type_)r!rr"r)r<r!rrr�_init_param�s
racCs�d}xB|D]:}|jr
|jtkr(|jtks.d}q
|r
td|j�d���q
Wdd�|D�}|�ttd��g}x(|D] }t||||�} | rp|� | �qpW|r�d�
d d
�|D��}
|� |�dt�d|
�d
��|s�dg}td|gdd�|D�|||dd�S)NFTznon-default argument z follows default argumentcSsi|]}|jd|j���qS)Z_type_)r r)r;r<rrr�
<dictcomp>�sz_init_fn.<locals>.<dictcomp>)r�_HAS_DEFAULT_FACTORYr9css|]}|jtkr|jVqdS)N)r(rr)r;r<rrrrU�sz_init_fn.<locals>.<genexpr>r:r8r,�passrcSsg|]}|jrt|��qSr)r%ra)r;r<rrrr>sz_init_fn.<locals>.<listcomp>)rPrOrQ)
r%r!rr"� TypeErrorr�updatercr`�appendr?�_POST_INIT_NAMEr[)rr6�
has_post_initr^rOZseen_defaultr<rPZ
body_lines�lineZ
params_strrrr�_init_fn�s6
rkcCs2tdddd�dd�|D��dg|d�}t|�S) Nr)rz(return self.__class__.__qualname__ + f"(z, cSs g|]}|j�d|j�d��qS)z={self.z!r})r)r;r<rrrr>sz_repr_fn.<locals>.<listcomp>z)")rO)r[r?rN)rrO�fnrrr�_repr_fnsrmcCsp|td�}|r,dd�dd�|D��d}nd}tdd d
|�d�dd
f||d�tddd
|�d�ddf||d�fS)N)�clsrr8r9css|]}t|j�VqdS)N)r#r)r;r<rrrrUsz'_frozen_get_del_attr.<locals>.<genexpr>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))rPrO�__delattr__)rrz; raise FrozenInstanceError(f"cannot delete field {name!r}")z"super(cls, self).__delattr__(name))rr?r[)rnrrOrPZ
fields_strrrr�_frozen_get_del_attrs&
rrcCs$t|ddd|�|�|��dg|d�S)N)r�otherz%if other.__class__ is self.__class__:z return zreturn NotImplemented)rO)r[)r�op�
self_tuple�other_tuplerOrrr�_cmp_fn2srwcCs$td|�}tddd|�d�g|d�S)Nr�__hash__)rzreturn hash(r,)rO)r@r[)rrOrurrr�_hash_fn@s
rycCs$||jkp"t|�|jko"|j|jkS)N)�ClassVarr Z
_GenericAliasZ
__origin__)�a_type�typingrrr�_is_classvarHs
r}cCs
||jkS)N)r)r{�dataclassesrrr�_is_initvarPsrc Cs�t�|�}|r�d}|�d�}|s2tj�|j�j}n2tj�|j�}|rd|j�|�|krdtj�|j�j}|r�||�|�d��|�r�dSdS)N��TF)�_MODULE_IDENTIFIER_RE�match�group�sys�modules�getr�__dict__) Z
annotationrnZa_moduler{Zis_type_predicater�rZZmodule_name�modulerrr�_is_typeVs)
r�cCs8t||t�}t|t�r|}nt|tj�r,t}t|d�}||_||_t |_
tj�
d�}|r�t||�s�t|jt�r�t|j|||jt�r�t|_
|j
t kr�tjt}t||�s�t|jt�r�t|j|||jt�r�t|_
|j
ttfkr�|jtk r�td|j�d���|j
t k�r4t|jtttf��r4tdt|j��d|j�d���|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(r�r�r�r}�strr�rzrrrrrr"rer!�list�dictrKr7)rnZa_namer{r!r<r|r~rrr�
_get_field�s:
r�cCs||jkrdSt|||�dS)NTF)r��setattr)rnrr]rrr�_set_new_attribute�s
r�cCsdS)Nr)rnrrOrrr�_hash_set_none�sr�cCsdd�|D�}t||�S)NcSs(g|] }|jdkr|jrn|jr|�qS)N)r$r&)r;r<rrrr>�sz_hash_add.<locals>.<listcomp>)ry)rnrrO�fldsrrr� _hash_add�sr�cCstd|j����dS)Nz-Cannot overwrite attribute __hash__ in class )rer)rnrrOrrr�_hash_exception�sr�))FFFF)FFFT)FFTF)FFTT)FTFF)FTFT)FTTF)FTTT)TFFF)TFFT)TFTF)TFTT)TTFF)TTFT)TTTF)TTTTcs�i}�jtjkr tj�jj}ni}t�tt||||||��d} d}
xX�jddd�D]D}t|t d�}|rXd}
x|�
�D]}
|
||
j<qzWt|t�jrXd} qXW�j�
di�}�fdd�|��D�}xT|D]L}
|
||
j<tt�|
jd�t�r�|
jtk�rt�|
j�q�t�|
j|
j�q�Wx<�j��D].\}}t|t��r&||k�r&t|�d����q&W|
�r�| �rr|�srtd ��| �s�|�r�td
��t�t |��j�
dt�}|tk�p�|dk�o�d�jk}|�r�|�s�td
��|�rt�t�}dd�|�
�D�}t�dt|||d|k�rdnd|��dd�|�
�D�}|�rTdd�|D�}t�dt||��|�r�dd�|D�}td|�}td|�}t�dtdd|||d��|�rdd�|D�}td|�}td|�}xFdD]>\}}t�|t|||||d���r�td|�d�j�d����q�W|�rLx>t�||�D].}t�|j|��rtd|j�d�j�����qWtt |�t |�t |�|f}|�r||�||��_!t�d��s��jt"t#�$����%dd ��_&�S)!NF���rT�__annotations__csg|]\}}t�||��qSr)r�)r;rr )rnrrr>Qsz"_process_class.<locals>.<listcomp>z& is a field but has no type annotationz5cannot inherit non-frozen dataclass from a frozen onez5cannot inherit frozen dataclass from a non-frozen onerx�__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>�srsz==)rOcSsg|]}|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 -> NonerR)'rr�r�r�r��_PARAMSr2�__mro__r.�_FIELDS�valuesrr6r��itemsr�rr!r�delattrrer7�hasattrrhr�rkrmr@rwrrr�_hash_action�boolrxr��inspectZ signaturerr�)rnr%r#r3r4r5r6rrOZany_frozen_baseZhas_dataclass_basesrTZbase_fieldsr<Zcls_annotationsZ
cls_fieldsrr]Z
class_hashZhas_explicit_hashrir�Z
field_listrurvrtrlZhash_actionr)rnr�_process_classs�
r�F)r%r#r3r4r5r6cs*������fdd�}|dkr"|S||�S)a�Returns the same class as was passed in, with dunder methods
added 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 function is added. If frozen is true, fields may
not be assigned to after instance creation.
cst|�������S)N)r�)rn)r3r6r%r4r#r5rr�wrap�szdataclass.<locals>.wrapNr)�_clsr%r#r3r4r5r6r�r)r3r6r%r4r#r5rr�scCsByt|t�}Wntk
r*td��YnXtdd�|��D��S)z�Return 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 instancecss|]}|jtkr|VqdS)N)r(r)r;r<rrrrUszfields.<locals>.<genexpr>)r.r��AttributeErrorre�tupler�)Zclass_or_instancerrrrr�s
cCstt|�t�S)z2Returns True if obj is an instance of a dataclass.)r�r r�)�objrrr�_is_dataclass_instancesr�cCs t|t�r|nt|�}t|t�S)zEReturns True if obj is a dataclass or an instance of a
dataclass.)r�r r�r�)r�rnrrrr
s)�dict_factorycCst|�std��t||�S)a�Return 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)r�re�
_asdict_inner)r�r�rrrr scs�t|�rHg}x2t|�D]&}tt||j���}|�|j|f�qW�|�St|t�rvt|d�rvt |��fdd�|D��St|t
tf�r�t |��fdd�|D��St|t�r�t |��fdd�|��D��St
�|�SdS)N�_fieldscsg|]}t|���qSr)r�)r;�v)r�rrr>Fsz!_asdict_inner.<locals>.<listcomp>c3s|]}t|��VqdS)N)r�)r;r�)r�rrrUKsz _asdict_inner.<locals>.<genexpr>c3s&|]\}}t|��t|��fVqdS)N)r�)r;�kr�)r�rrrUMs)r�rr�r.rrgr�r�r�r r�r�r��copy�deepcopy)r�r�rGr<r]r)r�rr�+s
r�)�
tuple_factorycCst|�std��t||�S)a�Return 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)r�re�_astuple_inner)r�r�rrrr
Tscs�t|�rBg}x,t|�D] }tt||j���}|�|�qW�|�St|t�rpt|d�rpt |��fdd�|D��St|t
tf�r�t |��fdd�|D��St|t�r�t |��fdd�|��D��St
�|�SdS)Nr�csg|]}t|���qSr)r�)r;r�)r�rrr>zsz"_astuple_inner.<locals>.<listcomp>c3s|]}t|��VqdS)N)r�)r;r�)r�rrrUsz!_astuple_inner.<locals>.<genexpr>c3s&|]\}}t|��t|��fVqdS)N)r�)r;r�r�)r�rrrU�s)r�rr�r.rrgr�r�r�r r�r�r�r�r�)r�r�rGr<r]r)r�rr�ls
r�r)�bases� namespacer%r#r3r4r5r6c s�dkri�n����t�}
i}x�|D]�}t|t�r>|}
d}nDt|�dkrT|\}
}n.t|�dkrt|\}
}}|�|
<ntd|����t|
t�r�|
��s�td|
����t�|
�r�td|
����|
|
kr�td|
����|
� |
�|||
<q&W|�d <t
�||i�fd
d��}t||||||| d�S)
a�Return 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.Anyr��zInvalid field: z'Field names must be valid identifiers: z"Field names must not be keywords: zField name duplicated: r�cs
|���S)N)rf)rZ)r�rr�<lambda>��z make_dataclass.<locals>.<lambda>)r%r#r3r4r5r6)
r�rKr�r��lenre�isidentifier�keyword� iskeywordrDr*� new_classr)Zcls_namerr�r�r%r#r3r4r5r6�seenZanns�itemr�tp�specrnr)r�rr�s6
cOs�t|�dkr tdt|��d���|r,|\}nd|kr@|�d�}ntd��t|�sXtd��x~t|t���D]l}|jtkrxqh|j s�|j
|krhtd|j
�d���qh|j
|krh|jtkr�td |j
�d
���t||j
�||j
<qhW|j
f|�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
r�z*replace() takes 1 positional argument but z were givenr�z7replace() 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())r�re�popr�r.r�r�r(rr%rr7r� __class__)rYZchangesr�r<rrrr�s*
)N)B�rer�r�r*r�r�rVrLrB�__all__r�rrrcrrr+r)rrrrr�r�rh�compiler�r rrrr2rr@rNr[r_r`rarkrmrrrwryr}rr�r�r�r�r�r�r�r�rrr�r
r�r r�r�r
r�rrrrrr�<module>s�
:62;RA
)@