#!/usr/bin/env python
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""A simple tool to go through histograms.xml and print out the owners for
histograms.
"""

import xml.etree.ElementTree

DUMMY_OWNER = "Please list the metric's owners. Add more owner tags as needed."

def main():
  tree = xml.etree.ElementTree.parse('histograms.xml')
  root = tree.getroot()
  assert root.tag == 'histogram-configuration'

  root_children = root.getchildren()
  histograms = None
  for node in root_children:
    if node.tag == 'histograms':
      histograms = node
      break
  assert histograms != None

  for histogram in histograms.getchildren():
    if histogram.tag != 'histogram':
      continue

    name = histogram.attrib['name']
    owners = []
    obsolete = False
    for node in histogram.getchildren():
      if node.tag == 'obsolete':
        obsolete = True
        continue
      if node.tag != 'owner':
        continue
      if node.text == DUMMY_OWNER:
        continue
      assert '@' in node.text
      owners.append(node.text)

    if not obsolete:
      if owners:
        print name, ' '.join(owners)
      else:
        print name, 'NO_OWNER'

if __name__ == '__main__':
  main()

Add a script to print out histogram ownership.
Metrics: Add a script to print out histogram ownership.

NOTRY=true

Review URL: https://codereview.chromium.org/456943002

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@288484 0039d316-1c4b-4281-b951-d872f2087c98
