code: def FieldDefinitionProtosFromTuples(field_def_tuples):
    
    # TODO: This needs fixing for Python 3.
    field_def_protos = []
    for field_name, field_type in field_def_tuples:
      if field_type in (int, long):
        field_type = rdf_stats.MetricFieldDefinition.FieldType.INT
      elif issubclass(field_type, Text):
        field_type = rdf_stats.MetricFieldDefinition.FieldType.STR
      else:
        raise ValueError("Invalid field type: %s" % field_type)
      field_def_protos.append(
          rdf_stats.MetricFieldDefinition(
              field_name=field_name, field_type=field_type))
    return field_def_protos
docs: Converts (field-name, type) tuples to MetricFieldDefinition protos.