Viewing File: /opt/hc_python/lib/python3.12/site-packages/aenum/__pycache__/_constant.cpython-312.pyc

�

^��g�����ddl�ddgZdZGd�de�ZGd�de�Zeejde	f�d	e
��
�Zedd��Zed��Z
ed
��Zede	fej��ZeZ[y)�)�*�
NamedConstant�ConstantNc�,��eZdZdZ�fd�Z�fd�Z�xZS)�NamedConstantDictz�Track constant order and ensure names are not reused.

    NamedConstantMeta will use the names found in self._names as the
    Constant names.
    c�8��tt|��g|_y�N)�superr�__init__�_names)�self�	__class__s ��>/opt/hc_python/lib/python3.12/site-packages/aenum/_constant.pyrzNamedConstantDict.__init__s���
���/�1����c�L��t|�rtd|�d���t|�rni||jvrt	d|����t|t�st|�s2||vrt	|�d||����|jj|�tt|�/||�y)z�Changes anything not dundered or not a constant descriptor.

        If an constant name is used twice, an error is raised; duplicate
        values are not checked for.

        Single underscore (sunder) names are reserved.
        z_sunder_ names, such as z+, are reserved for future NamedConstant usezattempt to reuse name: z already defined as: N)�	is_sunder�
ValueError�	is_dunderr�	TypeError�
isinstance�constant�
is_descriptor�appendr
r�__setitem__)r
�key�valuers   �rrzNamedConstantDict.__setitem__s�����S�>�����
��s�^��
�D�K�K�
��3�A�B�B�
��x�
(�
�e�0D��d�{��s�D��I� N�O�O��K�K���s�#�
���2�3��>r)�__name__�
__module__�__qualname__�__doc__rr�
__classcell__�rs@rrrs����
�?�?rrc�b��eZdZdZed��Z�fd�Zd�Z�fd�Zd�Z	d�Z
d�ZeZ�fd	�Z
�xZS)
�NamedConstantMetaz>
    Block attempts to reassign NamedConstant attributes.
    c��t�Sr	)r)�metacls�cls�bases�kwdss    r�__prepare__zNamedConstantMeta.__prepare__4s�� �"�"rc����t|�tur)|}t�}|j�D]
\}}|||<�i}i}|j�D]:\}	}
|	|jvr|
||	<�t|
t�r|
j}
|
||	<�<tt|�+||||�}i|_i|_|j�D]'\}	}
|j||	|
�}||j|	<�)|Sr	)
�type�dictr�itemsrr�	nonmemberrr
r$�__new__�_named_constant_cache_�	_members_)r&r'r(�clsdict�
original_dict�k�v�newdict�	constants�name�obj�newcls�new_krs             �rr0zNamedConstantMeta.__new__8s������=�D� �#�M�'�)�G�%�+�+�-���1����
�.����	� ����I�D�#��w�~�~�%�"%�	�$����C��+��i�i���G�D�M�
)��(�'�:�7�C��PW�X��(*��%����"���*�I�D�#��N�N�6�4��5�E�%*�F���T�"�+��
rc��y)NT��r's r�__bool__zNamedConstantMeta.__bool__Os��rc����|jj|�}t�@t|t�r0t	d|j
j�d|j�d���tt|�+|�y)Nzcannot delete constant <�.�>)�__dict__�getrr�AttributeErrorrr�_name_r
r$�__delattr__)r'�attr�cur_objrs   �rrHzNamedConstantMeta.__delattr__RsY����,�,�"�"�4�(���$��G�]�)K� �W�EV�EV�E_�E_�ah�ao�ao�!p�q�q�
���1�$�7rc�D�d�|jj�D�S)Nc3� K�|]}|���y�wr	r>��.0r5s  r�	<genexpr>z-NamedConstantMeta.__iter__.<locals>.<genexpr>Ys����2�1�a��1���)r2�valuesr?s r�__iter__zNamedConstantMeta.__iter__Xs��2�3�=�=�/�/�1�2�2rc�V�d�t|jj��D�S)Nc3� K�|]}|���y�wr	r>rMs  rrOz1NamedConstantMeta.__reversed__.<locals>.<genexpr>\s����<�;�a��;�rP)�reversedr2rQr?s r�__reversed__zNamedConstantMeta.__reversed__[s��<�8�C�M�M�$8�$8�$:�;�<�<rc�,�t|j�Sr	)�lenr2r?s r�__len__zNamedConstantMeta.__len__^s���3�=�=�!�!rc����|jj|�}t�@t|t�r0t	d|j
j�d|j�d���tt|�+||�y)z3Block attempts to reassign NamedConstants.
        N�cannot rebind constant <rBrC)rDrErrrFrrrGr
r$�__setattr__)r'r9rrJrs    �rr\zNamedConstantMeta.__setattr__cs]����,�,�"�"�4�(���$��G�]�)K� �W�EV�EV�E_�E_�ah�ao�ao�!p�q�q�
���1�$��>r)rrrr �classmethodr*r0r@rHrRrVrY�__nonzero__r\r!r"s@rr$r$/sK�����#��#��.�8�3�=�"��K�?�?rr$zPNamedConstants protection.

    Derive from this class to lock NamedConstants.

)r-�doc�nsc�z�|�^|}|jj�D]%\}}t||�s�|j|k(s�#|cSt	|�d|j
����|jj
|�}t|t�r0td|jj
�d|j�d���t|t�r|xs|j}|j}|j}t|t�r|j}t|�}|jj
|�}|�:t|j
|t|�fi�}||jt|�<|j!||�}||_
||_||_||j"|<|j%|||�|S)Nz does not exist in r[rBrC)rDr.r�_value_rrrErrFrrGrr rr,r1r0r2r\)	r'r9rr_r:rJr&�actual_type�
value_types	         rr0r0qsu���}������+�+�-�I�D�#��#�s�#����u�(<��
�.��%����N�O�O��l�l���t�$�G��'�=�)���AR�AR�A[�A[�]d�]k�]k�l�m�m�	�E�8�	$��"�U�]�]�������m�m�G��%��'��
�
���u�+�K��+�+�/�/��<�J����#�,�,��d�5�k�(:�B�?�
�2<��"�"�4��;�/�
�
�
�j�%�
0�C��C�J��C�K��C�K��C�M�M�$������T�3�'��Jrc�j�d|jj�d|j�d|j�d�S)N�<rBz: rC)rrrGrb)r
s r�__repr__rg�s)��
�N�N�#�#�T�[�[�$�,�,�@�@rc�>�t|j|jffSr	)�getattrrrG)r
�protos  r�
__reduce_ex__rk�s���T�^�^�T�[�[�1�1�1r)NN)�_common�__all__rr-rr,r$�	_Addendumr*�object�globals�
constant_dictr0rgrk�resolverr>rr�<module>rss����	��
���
�!?��!?�H:?��:?�x�
�
*�
*�?�V�J�
G�b��9�
�
�����@�@��@��2��2�"�/�F�:�}�?T�?T�?V�W�
���r
Back to Directory File Manager