def AddFieldsToDocumentPb(doc_id, fields, document):
 if (doc_id is not None):
  document.set_id(doc_id)
 for field_tuple in fields:
  name = field_tuple[0]
  value = field_tuple[1]
  field = document.add_field()
  field.set_name(name)
  field_value = field.mutable_value()
  field_value.set_string_value(value)
  if (len(field_tuple) > 2):
   field_value.set_type(field_tuple[2])

def AddFieldsToDocumentPb ( doc_id , fields , document ) : if ( doc_id is not None ) : document . set_id ( doc_id ) for field_tuple in fields : name = field_tuple [ 0 ] value = field_tuple [ 1 ] field = document . add_field ( ) field . set_name ( name ) field_value = field . mutable_value ( ) field_value . set_string_value ( value ) if ( len ( field_tuple ) > 2 ) : field_value . set_type ( field_tuple [ 2 ] )
add the id and fields to document .