def describe_field(field_definition):
 field_descriptor = FieldDescriptor()
 field_descriptor.name = field_definition.name
 field_descriptor.number = field_definition.number
 field_descriptor.variant = field_definition.variant
 if isinstance(field_definition, messages.EnumField):
  field_descriptor.type_name = field_definition.type.definition_name()
 if isinstance(field_definition, messages.MessageField):
  field_descriptor.type_name = field_definition.message_type.definition_name()
 if (field_definition.default is not None):
  field_descriptor.default_value = _DEFAULT_TO_STRING_MAP[type(field_definition)](field_definition.default)
 if field_definition.repeated:
  field_descriptor.label = FieldDescriptor.Label.REPEATED
 elif field_definition.required:
  field_descriptor.label = FieldDescriptor.Label.REQUIRED
 else:
  field_descriptor.label = FieldDescriptor.Label.OPTIONAL
 return field_descriptor

def describe_field ( field_definition ) : field_descriptor = FieldDescriptor ( ) field_descriptor . name = field_definition . name field_descriptor . number = field_definition . number field_descriptor . variant = field_definition . variant if isinstance ( field_definition , messages . EnumField ) : field_descriptor . type_name = field_definition . type . definition_name ( ) if isinstance ( field_definition , messages . MessageField ) : field_descriptor . type_name = field_definition . message_type . definition_name ( ) if ( field_definition . default is not None ) : field_descriptor . default_value = _DEFAULT_TO_STRING_MAP [ type ( field_definition ) ] ( field_definition . default ) if field_definition . repeated : field_descriptor . label = FieldDescriptor . Label . REPEATED elif field_definition . required : field_descriptor . label = FieldDescriptor . Label . REQUIRED else : field_descriptor . label = FieldDescriptor . Label . OPTIONAL return field_descriptor
build descriptor for field instance .