Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / tools / metrics / histograms / histogram_ownership.py
bloba4eee34d6d26bc374c29468f7bb88d8cf05fd5b2
1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """A simple tool to go through histograms.xml and print out the owners for
7 histograms.
8 """
10 import os
11 import sys
12 import xml.etree.ElementTree
14 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common'))
15 import path_util
17 DUMMY_OWNER = "Please list the metric's owners. Add more owner tags as needed."
19 def main():
20 tree = xml.etree.ElementTree.parse(path_util.GetHistogramsFile())
21 root = tree.getroot()
22 assert root.tag == 'histogram-configuration'
24 root_children = root.getchildren()
25 histograms = None
26 for node in root_children:
27 if node.tag == 'histograms':
28 histograms = node
29 break
30 assert histograms != None
32 for histogram in histograms.getchildren():
33 if histogram.tag != 'histogram':
34 continue
36 name = histogram.attrib['name']
37 owners = []
38 obsolete = False
39 for node in histogram.getchildren():
40 if node.tag == 'obsolete':
41 obsolete = True
42 continue
43 if node.tag != 'owner':
44 continue
45 if node.text == DUMMY_OWNER:
46 continue
47 assert '@' in node.text
48 owners.append(node.text)
50 if not obsolete:
51 if owners:
52 print name, ' '.join(owners)
53 else:
54 print name, 'NO_OWNER'
56 if __name__ == '__main__':
57 main()