관리-도구
편집 파일: _constant.cpython-38.pyc
U )�e� � @ s� d dl T ddgZdZG dd� de�ZG dd� de�Zee�de f�d e � d �Zeddd��Zed d� �Z edd� �Zede fe�� �ZeZ[dS )� )�*� NamedConstant�ConstantNc s, e Zd ZdZ� fdd�Z� fdd�Z� ZS )�NamedConstantDictz�Track constant order and ensure names are not reused. NamedConstantMeta will use the names found in self._names as the Constant names. c s t t| ��� g | _d S �N)�superr �__init__�_names��self�� __class__� �=/opt/hc_python/lib/python3.8/site-packages/aenum/_constant.pyr s zNamedConstantDict.__init__c s� t |�rtd|f ��n^t|�r"nT|| jkr<td|f ��n:t|t�sNt|�sv|| krjtd|| | f ��| j�|� t t | ��||� dS )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. zE_sunder_ names, such as %r, are reserved for future NamedConstant usezattempt to reuse name: %rz%s already defined as: %rN)Z is_sunder� ValueErrorZ is_dunderr � TypeError� isinstance�constantZ is_descriptor�appendr r �__setitem__)r �key�valuer r r r s �� zNamedConstantDict.__setitem__)�__name__� __module__�__qualname__�__doc__r r � __classcell__r r r r r s r c sh e Zd ZdZedd� �Z� fdd�Zdd� Z� fdd �Zd d� Z dd � Z dd� ZeZ� fdd�Z � ZS )�NamedConstantMetaz> Block attempts to reassign NamedConstant attributes. c K s t � S r )r )�metacls�cls�bases�kwdsr r r �__prepare__4 s zNamedConstantMeta.__prepare__c s� t |�tkr0|}t� }|�� D ]\}}|||<