Converts (field-name, type) tuples to MetricFieldDefinition protos.

def FieldDefinitionProtosFromTuples(field_def_tuples):
  """Converts (field-name, type) tuples to MetricFieldDefinition protos."""
  # 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