tools/metrics/ukm/xml_validations.py
def checkMetricTypeIsSpecified(self):
    """Check each metric is either specified with an enum or a unit."""
    errors = []
    warnings = []

    enum_tree = merge_xml.MergeFiles([histogram_paths.ENUMS_XML])
    enums, _ = extract_histograms.ExtractEnumsFromXmlTree(enum_tree)

    for event_node in self.config.getElementsByTagName('event'):
      for metric_node in event_node.getElementsByTagName('metric'):
        if metric_node.hasAttribute('enum'):
          enum_name = metric_node.getAttribute('enum');
          # Check if the enum is defined in enums.xml.
          if enum_name not in enums:
            errors.append("Unknown enum %s in ukm metric %s:%s." %
                          (enum_name, event_node.getAttribute('name'),
                          metric_node.getAttribute('name')))
        elif not metric_node.hasAttribute('unit'):
          warnings.append("Warning: Neither \'enum\' or \'unit\' is specified "
                          "for ukm metric %s:%s."
                          % (event_node.getAttribute('name'),
                             metric_node.getAttribute('name')))

    isSuccess = not errors
    return (isSuccess, errors, warnings)
Check each metric is either specified with an enum or a unit.
Check each metric is either specified with an enum or a unit.
Check each metric is either specified with an enum or a unit .
def checkMetricTypeIsSpecified(self):
    errors = []
    warnings = []
    enum_tree = merge_xml.MergeFiles([histogram_paths.ENUMS_XML])
    enums, _ = extract_histograms.ExtractEnumsFromXmlTree(enum_tree)
    for event_node in self.config.getElementsByTagName('event'):
      for metric_node in event_node.getElementsByTagName('metric'):
        if metric_node.hasAttribute('enum'):
          enum_name = metric_node.getAttribute('enum');
          if enum_name not in enums:
            errors.append("Unknown enum %s in ukm metric %s:%s." %
                          (enum_name, event_node.getAttribute('name'),
                          metric_node.getAttribute('name')))
        elif not metric_node.hasAttribute('unit'):
          warnings.append("Warning: Neither \'enum\' or \'unit\' is specified "
                          "for ukm metric %s:%s."
                          % (event_node.getAttribute('name'),
                             metric_node.getAttribute('name')))
    isSuccess = not errors
    return (isSuccess, errors, warnings)
def checkMetricTypeIsSpecified ( self ) : errors = [ ] warnings = [ ] enum_tree = merge_xml . MergeFiles ( [ histogram_paths . ENUMS_XML ] ) enums , _ = extract_histograms . ExtractEnumsFromXmlTree ( enum_tree ) for event_node in self . config . getElementsByTagName ( 'event' ) : for metric_node in event_node . getElementsByTagName ( 'metric' ) : if metric_node . hasAttribute ( 'enum' ) : enum_name = metric_node . getAttribute ( 'enum' ) ; if enum_name not in enums : errors . append ( "Unknown enum %s in ukm metric %s:%s." % ( enum_name , event_node . getAttribute ( 'name' ) , metric_node . getAttribute ( 'name' ) ) ) elif not metric_node . hasAttribute ( 'unit' ) : warnings . append ( "Warning: Neither \'enum\' or \'unit\' is specified " "for ukm metric %s:%s." % ( event_node . getAttribute ( 'name' ) , metric_node . getAttribute ( 'name' ) ) ) isSuccess = not errors return ( isSuccess , errors , warnings )
Check each metric is either specified with an enum or a unit.
Check each metric is either specified with an enum or a unit .
"""Check each metric is either specified with an enum or a unit.""" # Check if the enum is defined in enums.xml.
self