def describe_enum(enum_definition):
 enum_descriptor = EnumDescriptor()
 enum_descriptor.name = enum_definition.definition_name().split('.')[(-1)]
 values = []
 for number in enum_definition.numbers():
  value = enum_definition.lookup_by_number(number)
  values.append(describe_enum_value(value))
 if values:
  enum_descriptor.values = values
 return enum_descriptor

def describe_enum ( enum_definition ) : enum_descriptor = EnumDescriptor ( ) enum_descriptor . name = enum_definition . definition_name ( ) . split ( '.' ) [ ( - 1 ) ] values = [ ] for number in enum_definition . numbers ( ) : value = enum_definition . lookup_by_number ( number ) values . append ( describe_enum_value ( value ) ) if values : enum_descriptor . values = values return enum_descriptor
build descriptor for enum class .