AlkantarClanX12

Your IP : 18.216.145.37


Current Path : /proc/self/root/opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python39/lib64/python3.9/__pycache__/dataclasses.cpython-39.pyc

a

R�f���@stddlZddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	gd�Z
Gdd�de�ZGdd�d�Z
e
�ZGdd	�d	�Ze�Ze�i�ZGd
d�d�Zed�Zed
�Zed�ZdZdZdZe�d�ZGdd�d�ZGdd�d�ZGdd�d�Zeedddddd�dd�Zdd�Z dd �Z!dded!�d"d#�Z"d$d%�Z#d&d'�Z$d(d)�Z%d*d+�Z&d,d-�Z'd.d/�Z(d0d1�Z)d2d3�Z*d4d5�Z+d6d7�Z,d8d9�Z-d:d;�Z.d<d=�Z/d>d?�Z0d@dA�Z1dBdC�Z2dddde0de1de1e2e1e2e1e2e1e2dD�Z3dEdF�Z4daddddGdGdGdH�dIdJ�Z5dKdL�Z6dMdN�Z7dOdP�Z8e9dQ�dRdS�Z:dTdU�Z;e<dV�dWdX�Z=dYdZ�Z>d[dddddGdGdGd\�d]d^�Z?d_d`�Z@dS)b�N)�GenericAlias)�	dataclass�field�Field�FrozenInstanceError�InitVar�MISSING�fields�asdict�astuple�make_dataclass�replace�is_dataclassc@seZdZdS)rN��__name__�
__module__�__qualname__�rr�0/opt/alt/python39/lib64/python3.9/dataclasses.pyr��rc@seZdZdd�ZdS)�_HAS_DEFAULT_FACTORY_CLASScCsdS)Nz	<factory>r��selfrrr�__repr__�sz#_HAS_DEFAULT_FACTORY_CLASS.__repr__N)rrrrrrrrr�src@seZdZdS)�
_MISSING_TYPENrrrrrr�src@seZdZdd�Zdd�ZdS)�_FIELD_BASEcCs
||_dS�N��name�rrrrr�__init__�sz_FIELD_BASE.__init__cCs|jSrrrrrrr�sz_FIELD_BASE.__repr__N)rrrr rrrrrr�sr�_FIELD�_FIELD_CLASSVAR�_FIELD_INITVARZ__dataclass_fields__Z__dataclass_params__Z
__post_init__z^(?:\s*(\w+)\s*\.)?\s*(\w+)c@s(eZdZdZdd�Zdd�Zdd�ZdS)	r��typecCs
||_dSrr$)rr%rrrr �szInitVar.__init__cCs8t|jt�r"t|jt�s"|jj}n
t|j�}d|�d�S)Nzdataclasses.InitVar[�])�
isinstancer%rr�repr)rZ	type_namerrrr�s

zInitVar.__repr__cCst|�Sr)r)�clsr%rrr�__class_getitem__�szInitVar.__class_getitem__N)rrr�	__slots__r rr*rrrrr�src@s0eZdZdZdd�Zdd�Zdd�Zee�Z	dS)	r)
rr%�default�default_factoryr(�hash�init�compare�metadata�_field_typecCsRd|_d|_||_||_||_||_||_||_|dur<tnt	�
|�|_d|_dSr)
rr%r,r-r/r(r.r0�_EMPTY_METADATA�types�MappingProxyTyper1r2)rr,r-r/r(r.r0r1rrrr �s��zField.__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=�,repr=z,hash=z	,compare=z
,metadata=z
,_field_type=�))
rr%r,r-r/r(r.r0r1r2rrrrrs*��������	�
�zField.__repr__cCs(tt|j�dd�}|r$||j||�dS)N�__set_name__)�getattrr%r,)r�ownerr�funcrrrr8szField.__set_name__N)
rrrr+r rr8�classmethodrr*rrrrr�s
rc@s eZdZdZdd�Zdd�ZdS)�_DataclassParams�r/r(�eq�order�unsafe_hash�frozencCs(||_||_||_||_||_||_dSrr>)rr/r(r?r@rArBrrrr ,sz_DataclassParams.__init__c
Cs6d|j�d|j�d|j�d|j�d|j�d|j�d�
S)Nz_DataclassParams(init=r6z,eq=z,order=z
,unsafe_hash=z,frozen=r7r>rrrrr4s������z_DataclassParams.__repr__N)rrrr+r rrrrrr=#sr=T�r,r-r/r(r.r0r1cCs,|tur|turtd��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�
ValueErrorrrCrrrrBs
�rcs(|sdSdd��fdd�|D���d�S)N�()�(�,csg|]}��d|j���qS)�.r��.0�f��obj_namerr�
<listcomp>arz_tuple_str.<locals>.<listcomp>�,))�join)rMr	rrLr�
_tuple_strXsrQcs"t��t�����fdd��}|S)Nc	sNt|�t��f}|�vrdS��|�z�|�}W��|�n��|�0|S)Nz...)�id�_thread�	get_ident�add�discard)r�key�result��repr_running�
user_functionrr�wrapperks

z _recursive_repr.<locals>.wrapper)�set�	functools�wraps)r[r\rrYr�_recursive_reprfs
r`)�globals�locals�return_typec
Cs�|duri}d|vrt|d<d}|tur4||d<d}d�|�}d�dd�|D��}d	|�d
|�d|�d|��}d
�|���}d|�d|�d|��}i}	t|||	�|	dfi|��S)NZBUILTINS�Z_return_typez->_return_typerG�
css|]}d|��VqdS)z  Nr)rJ�brrr�	<genexpr>�rz_create_fn.<locals>.<genexpr>z def rFr7z:
�, zdef __create_fn__(z):
z	
 return Z
__create_fn__)�builtinsrrP�keys�exec)
r�args�bodyrarbrcZreturn_annotationZtxtZ
local_vars�nsrrr�
_create_fnys 
rocCs0|rd|�d|�d|�d�S|�d|�d|��S)NzBUILTINS.object.__setattr__(rGr7rH�=r)rBr�value�	self_namerrr�
_field_assign�srscCs�d|j��}|jturV|jr@|j||<|�d|j�d|j��}q�|j||<|�d�}n8|jr�|jturn|j}q�|jtur�|j||<|j}ndS|jtur�dSt||j||�S)NZ_dflt_z() if z is _HAS_DEFAULT_FACTORY else rE)rr-rr/r,r2r#rs)rKrBrarrZdefault_namerqrrr�_field_init�s*

��




rtcCsV|jtur|jturd}n&|jtur2d|j��}n|jtur@d}|j�d|j�|��S)Nrdz=_dflt_z=_HAS_DEFAULT_FACTORYz:_type_)r,rr-r)rKr,rrr�_init_param�s

rucCs�d}|D]:}|jr|jtur&|jtus,d}q|rtd|j�d���qdd�|D�}|�ttd��g}|D] }t||||�}	|	rj|�	|	�qj|r�d�
d	d
�|D��}
|�	|�dt�d|
�d
��|s�dg}td|gdd�|D�|||dd�S)NFTznon-default argument z follows default argumentcSsi|]}d|j��|j�qS)Z_type_)rr%rIrrr�
<dictcomp>�rz_init_fn.<locals>.<dictcomp>)r�_HAS_DEFAULT_FACTORYrGcss|]}|jtur|jVqdSr)r2r#rrIrrrrgs
�z_init_fn.<locals>.<genexpr>rHrFr7�passr cSsg|]}|jrt|��qSr)r/rurIrrrrNrz_init_fn.<locals>.<listcomp>)rbrarc)
r/r,rr-�	TypeErrorr�updaterwrt�appendrP�_POST_INIT_NAMEro)r	rB�
has_post_initrrraZseen_defaultrKrbZ
body_lines�lineZ
params_strrrr�_init_fn�s:��rcCs2tdddd�dd�|D��dg|d�}t|�S)	Nrrz(return self.__class__.__qualname__ + f"(rhcSs g|]}|j�d|j�d��qS)z={self.z!r}rrIrrrrNs�z_repr_fn.<locals>.<listcomp>z)"�ra)rorPr`)r	ra�fnrrr�_repr_fns
����r�cCsp|td�}|r,dd�dd�|D��d}nd}tdd	d
|�d�dd
f||d�tddd
|�d�ddf||d�fS)N)r)rrFrGcss|]}t|j�VqdSr)r(rrIrrrrg*rz'_frozen_get_del_attr.<locals>.<genexpr>rOrE�__setattr__)rrrqz 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))rbra�__delattr__rz; raise FrozenInstanceError(f"cannot delete field {name!r}")z"super(cls, self).__delattr__(name))rrPro)r)r	rarbZ
fields_strrrr�_frozen_get_del_attr&s2�
��
���r�cCs$t|ddd|�|�|��dg|d�S)N)r�otherz%if other.__class__ is self.__class__:z return zreturn NotImplementedr�)ro)r�op�
self_tuple�other_tuplerarrr�_cmp_fn?s��r�cCs$td|�}tddd|�d�g|d�S)Nr�__hash__rzreturn hash(r7r�)rQro)r	rar�rrr�_hash_fnMs
�r�cCs$||jup"t|�|juo"|j|juSr)�ClassVarr%�
_GenericAlias�
__origin__)�a_type�typingrrr�_is_classvarUs

�r�cCs||jupt|�|juSr)rr%)r��dataclassesrrr�_is_initvar]s
�r�c	Cs�t�|�}|r�d}|�d�}|s2tj�|j�j}n2tj�|j�}|rd|j�|�|urdtj�|j�j}|r�||�|�d��|�r�dSdS)N��TF)�_MODULE_IDENTIFIER_RE�match�group�sys�modules�getr�__dict__)	�
annotationr)Za_moduler�Zis_type_predicater�rnZmodule_name�modulerrr�_is_typeds)

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	ur�tjt}t||�s�t|jt�r�t|j|||jt�r�t|_
|j
ttfvr�|jtur�td|j�d���|j
t	u�r4t|jtttf��r4tdt|j��d|j�d���|S)N)r,r��field z cannot have a default factoryzmutable default z for field z$ is not allowed: use default_factory)r9rr'rr4�MemberDescriptorTyperrr%r!r2r�r�r�r��strr�r�r"rr�rr#r-ryr,�list�dictr]rD)r)Za_namer�r,rKr�r�rrr�
_get_field�sJ



���



���
	 �
r�cCs||jvrdSt|||�dS)NTF)r��setattr)r)rrqrrr�_set_new_attribute�s
r�cCsdSrr�r)r	rarrr�_hash_set_none�sr�cCsdd�|D�}t||�S)NcSs(g|] }|jdur|jrn|jr|�qSr)r.r0rIrrrrNrz_hash_add.<locals>.<listcomp>)r�)r)r	ra�fldsrrr�	_hash_addsr�cCstd|j����dS)Nz-Cannot overwrite attribute __hash__ in class )ryrr�rrr�_hash_exceptions�r�))FFFF)FFFT)FFTF)FFTT)FTFF)FTFT)FTTF)FTTT)TFFF)TFFT)TFTF)TFTT)TTFF)TTFT)TTTF)TTTTcs�i}�jtjvr tj�jj}ni}t�tt||||||��d}	d}
�jddd�D]D}t|t	d�}|durVd}
|�
�D]}
|
||
j<qzt|t�jrVd}	qV�j�
di�}�fdd�|��D�}|D]L}
|
||
j<tt�|
jd�t�r�|
jtu�rt�|
j�q�t�|
j|
j�qĈj��D].\}}t|t��r||v�rt|�d����q|
�rz|	�rf|�sftd	��|	�sz|�rztd
��t�t	|��j�
dt�}|tu�p�|du�o�d�jv}|�r�|�s�td
��|�rt�t�}dd�|�
�D�}t�dt|||d|v�rdnd|��dd�|�
�D�}|�rHdd�|D�}t�dt||��|�r�dd�|D�}td|�}td|�}t�dtdd|||d��|�r�dd�|D�}td|�}td|�}dD]>\}}t�|t|||||d���r�td|�d�j�d����q�|�r8t�||�D].}t�|j|��rtd|j�d�j�����qtt |�t |�t |�|f}|�rh|�||��_!t�d��s��jt"t#�$����%dd ��_&�S)!NF���rT�__annotations__csg|]\}}t�||��qSr)r�)rJrr%�r)rrrN_s�z"_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 oner��__eq__z eq must be true if order is truecSsg|]}|jttfvr|�qSr)r2r!r#rIrrrrN�s�r rZ__dataclass_self__cSsg|]}|jtur|�qSr�r2r!rIrrrrN�rcSsg|]}|jr|�qSr)r(rIrrrrN�rrcSsg|]}|jr|�qSr�r0rIrrrrN�rr�z==r�cSsg|]}|jr|�qSrr�rIrrrrN�r))�__lt__�<)�__le__z<=)�__gt__�>)�__ge__z>=zCannot overwrite attribute z
 in class z). Consider using functools.total_ordering�__doc__z -> Nonerd)'rr�r�r�r��_PARAMSr=�__mro__r9�_FIELDS�valuesrrBr��itemsr'rr,r�delattrryrD�hasattrr|r�rr�rQr�rr��_hash_action�boolr�r��inspectZ	signaturer
r�)r)r/r(r?r@rArBr	raZany_frozen_baseZhas_dataclass_basesrfZbase_fieldsrKZcls_annotationsZ
cls_fieldsrrqZ
class_hashZhas_explicit_hashr}r�Z
field_listr�r�r�r�Zhash_actionrr�r�_process_class)s��
�

�
��

��


��
����r�Fr>cs*������fdd�}|dur"|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|�������Sr)r�r��r?rBr/r@r(rArr�wrap�szdataclass.<locals>.wrapNr)r)r/r(r?r@rArBr�rr�rr�srcCs@zt|t�}Wnty(td��Yn0tdd�|��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|]}|jtur|VqdSrr�rIrrrrgrzfields.<locals>.<genexpr>)r9r��AttributeErrorry�tupler�)Zclass_or_instancer	rrrr	s
r	cCstt|�t�S)z2Returns True if obj is an instance of a dataclass.)r�r%r�)�objrrr�_is_dataclass_instancesr�cCs*t|t�rt|t�s|nt|�}t|t�S)zEReturns True if obj is a dataclass or an instance of a
    dataclass.)r'r%rr�r�)r�r)rrrrs r��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�ry�
_asdict_inner)r�r�rrrr
sr
cs�t|�rDg}t|�D]&}tt||j���}|�|j|f�q�|�St|t�rrt|d�rrt	|��fdd�|D��St|t
tf�r�t	|��fdd�|D��St|t�r�t	|��fdd�|��D��St
�|�SdS)N�_fieldscsg|]}t|���qSr�r��rJ�vr�rrrNQrz!_asdict_inner.<locals>.<listcomp>c3s|]}t|��VqdSrr�r�r�rrrgVrz _asdict_inner.<locals>.<genexpr>c3s&|]\}}t|��t|��fVqdSrr��rJ�kr�r�rrrgXs��)r�r	r�r9rr{r'r�r�r%r�r�r��copy�deepcopy)r�r�rXrKrqrr�rr�6s
�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�ry�_astuple_inner)r�r�rrrr_srcs�t|�r>g}t|�D] }tt||j���}|�|�q�|�St|t�rlt|d�rlt	|��fdd�|D��St|t
tf�r�t	|��fdd�|D��St|t�r�t	|��fdd�|��D��St
�|�SdS)Nr�csg|]}t|���qSr�r�r�r�rrrN�rz"_astuple_inner.<locals>.<listcomp>c3s|]}t|��VqdSrr�r�r�rrrg�rz!_astuple_inner.<locals>.<genexpr>c3s&|]\}}t|��t|��fVqdSrr�r�r�rrrg�s�)r�r	r�r9rr{r'r�r�r%r�r�r�r�r�)r�r�rXrKrqrr�rr�ws
�r�r)�bases�	namespacer/r(r?r@rArBc	s�duri�n����t�}
i}|D]�}t|t�r<|}
d}nDt|�dkrR|\}
}n.t|�dkrr|\}
}}|�|
<ntd|����t|
t�r�|
��s�td|
����t�|
�r�td|
����|
|
vr�td|
����|
�	|
�|||
<q$|�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
|���Sr)rz)rn�r�rr�<lambda>�rz make_dataclass.<locals>.<lambda>r>)
r�r]r'r��lenry�isidentifier�keyword�	iskeywordrUr4�	new_classr)�cls_namer	r�r�r/r(r?r@rArB�seenZanns�itemr�tp�specr)rr�rr�s8






�rcKs�t|�std��t|t���D]v}|jtur.q|jsR|j|vrt	d|j�d���q|j|vr|jt
ur�|jtur�t	d|j�d���t||j�||j<q|j
fi|��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 instancesr�zC is declared with init=False, it cannot be specified with replace()zInitVar z! must be specified with replace())r�ryr9r�r�r2r"r/rrDr#r,r�	__class__)r�ZchangesrKrrrr
�s


r
)N)A�rer�r�r4r�r�rir^rSr�__all__r�rrrwrrr5r3rr!r"r#r�r�r|�compiler�rrr=rrQr`rorsrtrurr�r�r�r�r�r�r�r�r�r�r�r�r�r�rr	r�rr�r
r�r�rr�rr
rrrr�<module>s�

<��62;R�>
�)�B