U
    gr
                     @   s   d Z ddlZddlZddlmZmZmZ edZedZ	edej
dZee ee	eeee	f dd	d
ZG dd deej
ZG dd dejZdS )a  This module contains helper functions related to enums.

Warning:
    Contents of this module are intended to be used internally by the library and *not* by the
    user. Changes to this module are not considered breaking changes and may not be documented in
    the changelog.
    N)TypeTypeVarUnion_A_B_Enum)bound)enum_clsvaluedefaultreturnc                 C   s(   z
| |W S  t k
r"   | Y S X dS )zTries to call ``enum_cls(value)`` to convert the value into an enumeration member.
    If that fails, the ``default`` is returned.
    N)
ValueError)r	   r
   r    r   8/tmp/pip-unpacked-wheel-swnnwir2/telegram/_utils/enum.py
get_member#   s    
r   c                   @   s0   e Zd ZdZdZedddZedddZdS )	
StringEnumzHelper class for string enums where ``str(member)`` prints the value, but ``repr(member)``
    gives ``EnumName.MEMBER_NAME``.
    r   r   c                 C   s   d| j j d| j dS N<.>	__class____name__nameselfr   r   r   __repr__7   s    zStringEnum.__repr__c                 C   s
   t | S N)str__str__r   r   r   r   r    :   s    zStringEnum.__str__N)r   
__module____qualname____doc__	__slots__r   r   r    r   r   r   r   r   0   s   r   c                   @   s:   e Zd ZdZdZedddZejdk r6edddZ	d	S )
IntEnumzHelper class for int enums where ``str(member)`` prints the value, but ``repr(member)``
    gives ``EnumName.MEMBER_NAME``.
    r   r   c                 C   s   d| j j d| j dS r   r   r   r   r   r   r   F   s    zIntEnum.__repr__)      c                 C   s
   t | jS r   )r   r
   r   r   r   r   r    K   s    zIntEnum.__str__N)
r   r!   r"   r#   r$   r   r   sysversion_infor    r   r   r   r   r%   ?   s
   
r%   )r#   enumZ_enumr(   typingr   r   r   r   r   Enumr   r   r   r   r%   r   r   r   r   <module>   s   "