def define_enum(enum_descriptor, module_name):
 enum_values = (enum_descriptor.values or [])
 class_dict = dict(((value.name, value.number) for value in enum_values))
 class_dict['__module__'] = module_name
 return type(str(enum_descriptor.name), (messages.Enum,), class_dict)

def define_enum ( enum_descriptor , module_name ) : enum_values = ( enum_descriptor . values or [ ] ) class_dict = dict ( ( ( value . name , value . number ) for value in enum_values ) ) class_dict [ '__module__' ] = module_name return type ( str ( enum_descriptor . name ) , ( messages . Enum , ) , class_dict )
define enum class from descriptor .