U
    Â@Ûfk  ã                   @   s>   d dl Z d dlmZmZmZ eddd�ZG dd„ de jƒZdS )é    N)ÚTypeÚTypeVarÚUnionÚTIntEnumÚIntEnum)Úboundc                   @   sÂ   e Zd Zedd„ ƒZedd„ ƒZeee eedœdd„ƒZ	eee e
edœd	d
„ƒZeee ee
ef edœdd„ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZdS )r   c                 C   s>   |   |¡ t | |¡}|  |d ¡p0|  ¡ › |› �|_||_|S ©N)Ú_check_valueÚintÚ__new__Ú_extra_to_textÚ_prefixÚ_name_Ú_value_)ÚclsÚvalueÚval© r   úB/var/www/html/chatgpt/venv/lib/python3.8/site-packages/dns/enum.pyÚ	_missing_   s
    
zIntEnum._missing_c                 C   sD   |   ¡ }t|tƒst‚|dk s&||kr@|  ¡ }t|› d|› �ƒ‚d S )Nr   z$ must be an int between >= 0 and <= )Ú_maximumÚ
isinstancer
   Ú	TypeErrorÚ_short_nameÚ
ValueError)r   r   ÚmaxÚnamer   r   r   r	   !   s    
zIntEnum._check_value)r   ÚtextÚreturnc                 C   s®   |  ¡ }z
| | W S  tk
r&   Y nX |  |¡}|r:|S |  ¡ }| |¡r¢|t|ƒd …  ¡ r¢t|t|ƒd … ƒ}|  |¡ z
| |ƒW S  t	k
r    | Y S X |  
¡ ‚d S r   )ÚupperÚKeyErrorÚ_extra_from_textr   Ú
startswithÚlenÚisdigitr
   r	   r   Ú_unknown_exception_class)r   r   r   Úprefixr   r   r   Ú	from_text*   s"    




zIntEnum.from_text)r   r   r   c                 C   sZ   |   |¡ z| |ƒj}W n tk
r0   d }Y nX |  ||¡}|d krV|  ¡ › |› �}|S r   )r	   r   r   r   r   )r   r   r   r   r   r   Úto_text>   s    

zIntEnum.to_textc                 C   s&   t |tƒr|  |¡S |  |¡ | |ƒS )a¥  Convert text or a value into an enumerated type, if possible.

        *value*, the ``int`` or ``str`` to convert.

        Raises a class-specific exception if a ``str`` is provided that
        cannot be converted.

        Raises ``ValueError`` if the value is out of range.

        Returns an enumeration from the calling class corresponding to the
        value, if one is defined, or an ``int`` otherwise.
        )r   Ústrr'   r	   )r   r   r   r   r   ÚmakeJ   s    


zIntEnum.makec                 C   s   t ‚d S r   )ÚNotImplementedError©r   r   r   r   r   ^   s    zIntEnum._maximumc                 C   s
   | j  ¡ S r   )Ú__name__Úlowerr,   r   r   r   r   b   s    zIntEnum._short_namec                 C   s   dS )NÚ r   r,   r   r   r   r   f   s    zIntEnum._prefixc                 C   s   d S r   r   )r   r   r   r   r   r!   j   s    zIntEnum._extra_from_textc                 C   s   |S r   r   )r   r   Zcurrent_textr   r   r   r   n   s    zIntEnum._extra_to_textc                 C   s   t S r   )r   r,   r   r   r   r%   r   s    z IntEnum._unknown_exception_classN)r-   Ú
__module__Ú__qualname__Úclassmethodr   r	   r   r   r)   r'   r
   r(   r   r*   r   r   r   r!   r   r%   r   r   r   r   r      s,   

 




)ÚenumÚtypingr   r   r   r   r   r   r   r   r   Ú<module>   s   