summaryrefslogtreecommitdiff
path: root/chromium/tools/metrics/histograms/histogram_ownership.py
blob: a4eee34d6d26bc374c29468f7bb88d8cf05fd5b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/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 os
import sys
import xml.etree.ElementTree

sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common'))
import path_util

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

def main():
  tree = xml.etree.ElementTree.parse(path_util.GetHistogramsFile())
  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()