

__all__ = [
    'get_enum_as_dict'
]


def get_enum_as_dict(cls, friendly_names=False):
    """
    Convert an "enum" class to a dict key is the enum name and value is an enum
    value.
    """
    result = {}
    for key, value in cls.__dict__.items():
        if key.startswith('__'):
            continue

        if key[0] != key[0].upper():
            continue

        name = key

        if friendly_names:
            name = name.replace('_', ' ').lower().title()

        result[name] = value

    return result



__all__ = [
    'get_enum_as_dict'
]


def get_enum_as_dict(cls, reverse=False, friendly_names=False):
    """
    Convert an "enum" class to a dict key is the enum name and value is an enum
    value.
    """
    result = {}
    for key, value in cls.__dict__.items():
        if key.startswith('__'):
            continue

        if key[0] != key[0].upper():
            continue

        name = key

        if friendly_names:
            name = name.replace('_', ' ').lower().title()

        if reverse:
            result[value] = name
        else:
            result[name] = value

    return result

Add 'reverse' argument to get_enum_as_dict.
Add 'reverse' argument to get_enum_as_dict.

  
  
  __all__ = [
      'get_enum_as_dict'
  ]
  
  
- def get_enum_as_dict(cls, friendly_names=False):
+ def get_enum_as_dict(cls, reverse=False, friendly_names=False):
      """
      Convert an "enum" class to a dict key is the enum name and value is an enum
      value.
      """
      result = {}
      for key, value in cls.__dict__.items():
          if key.startswith('__'):
              continue
  
          if key[0] != key[0].upper():
              continue
  
          name = key
  
          if friendly_names:
              name = name.replace('_', ' ').lower().title()
  
+         if reverse:
+             result[value] = name
+         else:
-         result[name] = value
+             result[name] = value
  
      return result
  
Add 'reverse' argument to get_enum_as_dict.
## Code Before:


__all__ = [
    'get_enum_as_dict'
]


def get_enum_as_dict(cls, friendly_names=False):
    """
    Convert an "enum" class to a dict key is the enum name and value is an enum
    value.
    """
    result = {}
    for key, value in cls.__dict__.items():
        if key.startswith('__'):
            continue

        if key[0] != key[0].upper():
            continue

        name = key

        if friendly_names:
            name = name.replace('_', ' ').lower().title()

        result[name] = value

    return result

## Instruction:
Add 'reverse' argument to get_enum_as_dict.
## Code After:


__all__ = [
    'get_enum_as_dict'
]


def get_enum_as_dict(cls, reverse=False, friendly_names=False):
    """
    Convert an "enum" class to a dict key is the enum name and value is an enum
    value.
    """
    result = {}
    for key, value in cls.__dict__.items():
        if key.startswith('__'):
            continue

        if key[0] != key[0].upper():
            continue

        name = key

        if friendly_names:
            name = name.replace('_', ' ').lower().title()

        if reverse:
            result[value] = name
        else:
            result[name] = value

    return result
