grr/core/grr_response_core/stats/stats_utils.py
def FieldDefinitionTuplesFromProtos(field_def_protos):
  """Converts MetricFieldDefinition protos to (field-name, type) tuples."""
  # TODO: This needs fixing for Python 3.
  field_def_tuples = []
  for proto in field_def_protos:
    if proto.field_type == rdf_stats.MetricFieldDefinition.FieldType.INT:
      field_type = int
    elif proto.field_type == rdf_stats.MetricFieldDefinition.FieldType.STR:
      # Use old style str in Python 2 here or the streamz library will break.
      field_type = compatibility.builtins.str
    else:
      raise ValueError("Unknown field type: %s" % proto.field_type)
    field_def_tuples.append((proto.field_name, field_type))
  return field_def_tuples
Converts MetricFieldDefinition protos to (field-name, type) tuples.
Converts MetricFieldDefinition protos to (field-name, type) tuples.
Converts MetricFieldDefinition protos to ( field - name type ) tuples .
def FieldDefinitionTuplesFromProtos(field_def_protos):
  field_def_tuples = []
  for proto in field_def_protos:
    if proto.field_type == rdf_stats.MetricFieldDefinition.FieldType.INT:
      field_type = int
    elif proto.field_type == rdf_stats.MetricFieldDefinition.FieldType.STR:
      field_type = compatibility.builtins.str
    else:
      raise ValueError("Unknown field type: %s" % proto.field_type)
    field_def_tuples.append((proto.field_name, field_type))
  return field_def_tuples
def FieldDefinitionTuplesFromProtos ( field_def_protos ) : field_def_tuples = [ ] for proto in field_def_protos : if proto . field_type == rdf_stats . MetricFieldDefinition . FieldType . INT : field_type = int elif proto . field_type == rdf_stats . MetricFieldDefinition . FieldType . STR : field_type = compatibility . builtins . str else : raise ValueError ( "Unknown field type: %s" % proto . field_type ) field_def_tuples . append ( ( proto . field_name , field_type ) ) return field_def_tuples
Converts MetricFieldDefinition protos to (field-name, type) tuples.
Converts MetricFieldDefinition protos to ( field - name type ) tuples .
"""Converts MetricFieldDefinition protos to (field-name, type) tuples.""" # TODO: This needs fixing for Python 3. # Use old style str in Python 2 here or the streamz library will break.
field_def_protos