@staticmethod
  def FieldsToFieldsDefinitions(fields):
    """Convert python-style fields definitions to rdfvalue-based definitions."""

    if not fields:
      return []

    result = []
    for field_name, field_type in fields:
      if field_type in (int, long):
        field_type = MetricFieldDefinition.FieldType.INT
      elif field_type == str:
        field_type = MetricFieldDefinition.FieldType.STR
      else:
        raise ValueError("Unknown field type: %s" % field_type)

      result.append(MetricFieldDefinition(field_name=field_name,
                                          field_type=field_type))
    return result
dataset/ETHPy150Open google/grr/grr/lib/stats.py/StatsCollector.FieldsToFieldsDefinitions/original