o
    Þý°je  ã                   @   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)ÚAnyÚTypeÚTypeVarÚTIntEnumÚIntEnum)Úboundc                   @   sè   e Zd Zedd„ ƒZedd„ ƒZedee dedefdd	„ƒZ	edee d
e
defdd„ƒZedee d
e
eB defdd„ƒZedd„ ƒZedd„ ƒZedefdd„ƒZedededB fdd„ƒZedd„ ƒZedee fdd„ƒZdS )r   c                 C   s>   |   |¡ t | |¡}|  |d ¡p|  ¡ › |› �|_||_|S ©N)Ú_check_valueÚintÚ__new__Ú_extra_to_textÚ_prefixÚ_name_Ú_value_)ÚclsÚvalueÚval© r   ú{/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/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_valuer   ÚtextÚreturnc                 C   sŒ   |  ¡ }z| | W S  ty   Y nw |  |¡}|r|S |  ¡ }| |¡rB|t|ƒd …  ¡ rBt|t|ƒd … ƒ}|  |¡ | |ƒS |  	¡ ‚r   )
ÚupperÚKeyErrorÚ_extra_from_textr   Ú
startswithÚlenÚisdigitr
   r	   Ú_unknown_exception_class)r   r   r   Úprefixr   r   r   Ú	from_text*   s   
ÿ

zIntEnum.from_textr   c                 C   sX   |   |¡ z| |ƒj}W n ty   d }Y nw |  ||¡}|d u r*|  ¡ › |› �}|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   ÚmakeG   s   


zIntEnum.makec                 C   s   t ‚r   )ÚNotImplementedError©r   r   r   r   r   [   ó   zIntEnum._maximumc                 C   s
   | j  ¡ S r   )Ú__name__Úlowerr,   r   r   r   r   _   s   
zIntEnum._short_namec                 C   s   dS )NÚ r   r,   r   r   r   r   c   r-   zIntEnum._prefixNc                 C   s   d S r   r   )r   r   r   r   r   r!   g   r-   zIntEnum._extra_from_textc                 C   s   |S r   r   )r   r   Úcurrent_textr   r   r   r   k   r-   zIntEnum._extra_to_textc                 C   s   t S r   )r   r,   r   r   r   r%   o   r-   z IntEnum._unknown_exception_class)r.   Ú
__module__Ú__qualname__Úclassmethodr   r	   r   r   r)   r'   r
   r(   r*   r   r   r   r   r!   r   Ú	Exceptionr%   r   r   r   r   r      s.    

 


)ÚenumÚtypingr   r   r   r   r   r   r   r   r   Ú<module>   s   