third_party/protobuf/python/google/protobuf/text_format.py
def PrintFieldValue(self, field, value):
    """Print a single field value (not including name).

    For repeated fields, the value should be a single element.

    Args:
      field: The descriptor of the field to be printed.
      value: The value of the field.
    """
    out = self.out
    if field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE:
      self._PrintMessageFieldValue(value)
    elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_ENUM:
      enum_value = field.enum_type.values_by_number.get(value, None)
      if enum_value is not None:
        out.write(enum_value.name)
      else:
        out.write(str(value))
    elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_STRING:
      out.write('\"')
      if isinstance(value, six.text_type) and (six.PY2 or not self.as_utf8):
        out_value = value.encode('utf-8')
      else:
        out_value = value
      if field.type == descriptor.FieldDescriptor.TYPE_BYTES:
        # We always need to escape all binary data in TYPE_BYTES fields.
        out_as_utf8 = False
      else:
        out_as_utf8 = self.as_utf8
      out.write(text_encoding.CEscape(out_value, out_as_utf8))
      out.write('\"')
    elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_BOOL:
      if value:
        out.write('true')
      else:
        out.write('false')
    elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_FLOAT:
      if self.float_format is not None:
        out.write('{1:{0}}'.format(self.float_format, value))
      else:
        if math.isnan(value):
          out.write(str(value))
        else:
          out.write(str(type_checkers.ToShortestFloat(value)))
    elif (field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_DOUBLE and
          self.double_format is not None):
      out.write('{1:{0}}'.format(self.double_format, value))
    else:
      out.write(str(value))
Print a single field value (not including name).

    For repeated fields, the value should be a single element.

    Args:
      field: The descriptor of the field to be printed.
      value: The value of the field.
    
Print a single field value (not including name).
For repeated fields, the value should be a single element.
Print a single field value ( not including name ) . For repeated fields the value should be a single element .
def PrintFieldValue(self, field, value):
    out = self.out
    if field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE:
      self._PrintMessageFieldValue(value)
    elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_ENUM:
      enum_value = field.enum_type.values_by_number.get(value, None)
      if enum_value is not None:
        out.write(enum_value.name)
      else:
        out.write(str(value))
    elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_STRING:
      out.write('\"')
      if isinstance(value, six.text_type) and (six.PY2 or not self.as_utf8):
        out_value = value.encode('utf-8')
      else:
        out_value = value
      if field.type == descriptor.FieldDescriptor.TYPE_BYTES:
        out_as_utf8 = False
      else:
        out_as_utf8 = self.as_utf8
      out.write(text_encoding.CEscape(out_value, out_as_utf8))
      out.write('\"')
    elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_BOOL:
      if value:
        out.write('true')
      else:
        out.write('false')
    elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_FLOAT:
      if self.float_format is not None:
        out.write('{1:{0}}'.format(self.float_format, value))
      else:
        if math.isnan(value):
          out.write(str(value))
        else:
          out.write(str(type_checkers.ToShortestFloat(value)))
    elif (field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_DOUBLE and
          self.double_format is not None):
      out.write('{1:{0}}'.format(self.double_format, value))
    else:
      out.write(str(value))
def PrintFieldValue ( self , field , value ) : out = self . out if field . cpp_type == descriptor . FieldDescriptor . CPPTYPE_MESSAGE : self . _PrintMessageFieldValue ( value ) elif field . cpp_type == descriptor . FieldDescriptor . CPPTYPE_ENUM : enum_value = field . enum_type . values_by_number . get ( value , None ) if enum_value is not None : out . write ( enum_value . name ) else : out . write ( str ( value ) ) elif field . cpp_type == descriptor . FieldDescriptor . CPPTYPE_STRING : out . write ( '\"' ) if isinstance ( value , six . text_type ) and ( six . PY2 or not self . as_utf8 ) : out_value = value . encode ( 'utf-8' ) else : out_value = value if field . type == descriptor . FieldDescriptor . TYPE_BYTES : out_as_utf8 = False else : out_as_utf8 = self . as_utf8 out . write ( text_encoding . CEscape ( out_value , out_as_utf8 ) ) out . write ( '\"' ) elif field . cpp_type == descriptor . FieldDescriptor . CPPTYPE_BOOL : if value : out . write ( 'true' ) else : out . write ( 'false' ) elif field . cpp_type == descriptor . FieldDescriptor . CPPTYPE_FLOAT : if self . float_format is not None : out . write ( '{1:{0}}' . format ( self . float_format , value ) ) else : if math . isnan ( value ) : out . write ( str ( value ) ) else : out . write ( str ( type_checkers . ToShortestFloat ( value ) ) ) elif ( field . cpp_type == descriptor . FieldDescriptor . CPPTYPE_DOUBLE and self . double_format is not None ) : out . write ( '{1:{0}}' . format ( self . double_format , value ) ) else : out . write ( str ( value ) )
Print a single field value (not including name).
Print a single field value ( not including name ) .
"""Print a single field value (not including name).

    For repeated fields, the value should be a single element.

    Args:
      field: The descriptor of the field to be printed.
      value: The value of the field.
    """ # We always need to escape all binary data in TYPE_BYTES fields.
self
field
The descriptor of the field to be printed.
The descriptor of the field to be printed .
value
The value of the field.
The value of the field .