Ejemplo n.º 1
0
def _addenumvalues(message_descriptor, dictionary):
  """sets class-level attributes for all enum fields defined in this message.

  args:
    message_descriptor: descriptor object for this message type.
    dictionary: class dictionary that should be populated.
  """
  for enum_type in message_descriptor.enum_types:
    dictionary[enum_type.name] = enum_type_wrapper.enumtypewrapper(enum_type)
    for enum_value in enum_type.values:
      dictionary[enum_value.name] = enum_value.number
Ejemplo n.º 2
0
def _addenumvalues(descriptor, cls):
  """sets class-level attributes for all enum fields defined in this message.

  also exporting a class-level object that can name enum values.

  args:
    descriptor: descriptor object for this message type.
    cls: class we're constructing for this message type.
  """
  for enum_type in descriptor.enum_types:
    setattr(cls, enum_type.name, enum_type_wrapper.enumtypewrapper(enum_type))
    for enum_value in enum_type.values:
      setattr(cls, enum_value.name, enum_value.number)