
    h                     ,    d Z ddlZd Z G d de      Zy)a  
Basic enumeration, providing ordered types for collections. These can be
constructed as simple type listings...

::

  >>> from stem.util import enum
  >>> insects = enum.Enum('ANT', 'WASP', 'LADYBUG', 'FIREFLY')
  >>> insects.ANT
  'Ant'
  >>> tuple(insects)
  ('Ant', 'Wasp', 'Ladybug', 'Firefly')

... or with overwritten string counterparts...

::

  >>> from stem.util import enum
  >>> pets = enum.Enum(('DOG', 'Skippy'), 'CAT', ('FISH', 'Nemo'))
  >>> pets.DOG
  'Skippy'
  >>> pets.CAT
  'Cat'

**Module Overview:**

::

  UppercaseEnum - Provides an enum instance with capitalized values

  Enum - Provides a basic, ordered  enumeration
    |- keys - string representation of our enum keys
    |- index_of - index of an enum value
    |- next - provides the enum after a given enum value
    |- previous - provides the enum before a given value
    |- __getitem__ - provides the value for an enum key
    +- __iter__ - iterator over our enum keys
    Nc                  <    t        | D cg c]  }||f c} S c c}w )a  
  Provides an :class:`~stem.util.enum.Enum` instance where the values are
  identical to the keys. Since the keys are uppercase by convention this means
  the values are too. For instance...

  ::

    >>> from stem.util import enum
    >>> runlevels = enum.UppercaseEnum('DEBUG', 'INFO', 'NOTICE', 'WARN', 'ERROR')
    >>> runlevels.DEBUG
    'DEBUG'

  :param list args: enum keys to initialize with

  :returns: :class:`~stem.util.enum.Enum` instance with the given keys
  )Enum)argsvs     X/var/www/betterdocs.net/sherlock_api/venv/lib/python3.12/site-packages/stem/util/enum.pyUppercaseEnumr   .   s!    $ 
%1A%	&&%s   c                   :    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
y	)
r   z
  Basic enumeration.
  c                 |   ddl m} g g }}|D ]  }t        j                  j	                  |      r| ||      }}n2t        |t              rt        |      dk(  r|\  }}nt        d|z        |j                  |       |j                  |       t        | ||        t        |      | _        t        |      | _        y )Nr   )_to_camel_case   zUnrecognized input: %s)stem.util.str_toolsr   stemutil_is_str
isinstancetuplelen
ValueErrorappendsetattr_keys_values)selfr   r   keysvaluesentrykeyvals           r   __init__zEnum.__init__H   s    2 r&D 
			5	!./SeU#E
aS1D899
kk#mmCdC
 tDJ=DL    c                 ,    t        | j                        S )zu
    Provides an ordered listing of the enumeration keys in this set.

    :returns: **list** with our enum keys
    )listr   )r   s    r   r   z	Enum.keys]   s     

r    c                 8    | j                   j                  |      S )z
    Provides the index of the given value in the collection.

    :param str value: entry to be looked up

    :returns: **int** index of the given entry

    :raises: **ValueError** if no such element exists
    )r   index)r   values     r   index_ofzEnum.index_off   s     <<e$$r    c                     || j                   vr+t        d|ddj                  | j                         d      | j                   j                  |      dz   t	        | j                         z  }| j                   |   S )z
    Provides the next enumeration after the given value.

    :param str value: enumeration for which to get the next entry

    :returns: enum value following the given entry

    :raises: **ValueError** if no such element exists
    No such enumeration exists:  (options: , )   r   r   joinr$   r   )r   r%   
next_indexs      r   nextz	Enum.nexts   i     DLL PTPYPYZ^ZfZfPghii,,$$U+a/3t||3DDJ<<
##r    c                     || j                   vr+t        d|ddj                  | j                         d      | j                   j                  |      dz
  t	        | j                         z  }| j                   |   S )z
    Provides the previous enumeration before the given value.

    :param str value: enumeration for which to get the previous entry

    :returns: enum value proceeding the given entry

    :raises: **ValueError** if no such element exists
    r(   r)   r*   r+   r,   r-   )r   r%   
prev_indexs      r   previouszEnum.previous   r1   r    c                     |t        |       v rt        | |      S dj                  | j                               }t	        d|d|      )z
    Provides the values for the given key.

    :param str item: key to be looked up

    :returns: **str** with the value for the given key

    :raises: **ValueError** if the key doesn't exist
    r*   'z4' isn't among our enumeration keys, which includes: )varsgetattrr.   r   r   )r   itemr   s      r   __getitem__zEnum.__getitem__   sC     tDzT4  YYtyy{#dVZ\`abbr    c              #   6   K   | j                   D ]  }|  yw)z?
    Provides an ordered listing of the enums in this set.
    N)r   )r   r   s     r   __iter__zEnum.__iter__   s      
  ks   N)__name__
__module____qualname____doc__r   r   r&   r0   r4   r:   r<    r    r   r   r   C   s+    !*%$"$"c"r    r   )r@   	stem.utilr   r   objectr   rA   r    r   <module>rD      s#   %N '*i6 ir    