
    <i                     ,    S r SSKrS r " S S\5      rg)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                  @    [        U  Vs/ s H  oU4PM     sn6 $ s  snf )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     H/home/james-whalen/.local/lib/python3.13/site-packages/stem/util/enum.pyUppercaseEnumr   .   s#    $ 
%1A%	&&%s   c                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)r   C   z
Basic enumeration.
c                    SSK Jn  / / pCU H  n[        R                  R	                  U5      (       a	  XR" U5      pvO7[        U[        5      (       a  [        U5      S:X  a  Uu  pgO[        SU-  5      eUR                  U5        UR                  U5        [        XU5        M     [        U5      U l        [        U5      U l        g )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__Enum.__init__H   s    2 r&			5	!	!./SeU##E
aS1D899
kk#mmCd  tDJ=DL    c                 ,    [        U R                  5      $ )zi
Provides an ordered listing of the enumeration keys in this set.

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

r"   c                 8    U R                   R                  U5      $ )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_ofEnum.index_off   s     <<e$$r"   c                     XR                   ;  a-  [        SU< SSR                  U R                   5      < S35      eU R                   R                  U5      S-   [	        U R                   5      -  nU R                   U   $ )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   next	Enum.nexts   g     LL PTPYPYZ^ZfZfPghii,,$$U+a/3t||3DDJ<<
##r"   c                     XR                   ;  a-  [        SU< SSR                  U R                   5      < S35      eU R                   R                  U5      S-
  [	        U R                   5      -  nU R                   U   $ )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/   r0   r1   )r   r(   
prev_indexs      r   previousEnum.previous   r6   r"   c                     U[        U 5      ;   a  [        X5      $ SR                  U R                  5       5      n[	        SU< SU< 35      e)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getattrr2   r   r   )r   itemr   s      r   __getitem__Enum.__getitem__   sA     tDzT  YYtyy{#dVZ\`abbr"   c              #   :   #    U R                    H  nUv   M	     g7f)z7
Provides an ordered listing of the enums in this set.
N)r   )r   r   s     r   __iter__Enum.__iter__   s     
 k s   )r   r   N)__name__
__module____qualname____firstlineno____doc__r    r   r)   r4   r9   r@   rC   __static_attributes__ r"   r   r   r   C   s+    !*%$"$"c"r"   r   )rI   	stem.utilr   r   objectr   rK   r"   r   <module>rN      s#   %N '*i6 ir"   