Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: tools/metrics/histograms/extract_histograms.py

Issue 2941623002: [Cleanup] Drop the redundant "type" attribute from enum entries. (Closed)
Patch Set: Rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/metrics/histograms/enums.xml ('k') | tools/metrics/histograms/print_style.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Extract histogram names from the description XML file. 5 """Extract histogram names from the description XML file.
6 6
7 For more information on the format of the XML file, which is self-documenting, 7 For more information on the format of the XML file, which is self-documenting,
8 see histograms.xml; however, here is a simple example to get you started. The 8 see histograms.xml; however, here is a simple example to get you started. The
9 XML below will generate the following five histograms: 9 XML below will generate the following five histograms:
10 10
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 177
178 178
179 def _ExtractEnumsFromXmlTree(tree): 179 def _ExtractEnumsFromXmlTree(tree):
180 """Extract all <enum> nodes in the tree into a dictionary.""" 180 """Extract all <enum> nodes in the tree into a dictionary."""
181 181
182 enums = {} 182 enums = {}
183 have_errors = False 183 have_errors = False
184 184
185 last_name = None 185 last_name = None
186 for enum in tree.getElementsByTagName('enum'): 186 for enum in tree.getElementsByTagName('enum'):
187 if enum.getAttribute('type') != 'int':
188 logging.error('Unknown enum type %s', enum.getAttribute('type'))
189 have_errors = True
190 continue
191
192 name = enum.getAttribute('name') 187 name = enum.getAttribute('name')
193 if last_name is not None and name.lower() < last_name.lower(): 188 if last_name is not None and name.lower() < last_name.lower():
194 logging.error('Enums %s and %s are not in alphabetical order', 189 logging.error('Enums %s and %s are not in alphabetical order',
195 last_name, name) 190 last_name, name)
196 have_errors = True 191 have_errors = True
197 last_name = name 192 last_name = name
198 193
199 if name in enums: 194 if name in enums:
200 logging.error('Duplicate enum %s', name) 195 logging.error('Duplicate enum %s', name)
201 have_errors = True 196 have_errors = True
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 tree = xml.dom.minidom.parse(f) 519 tree = xml.dom.minidom.parse(f)
525 histograms, had_errors = ExtractHistogramsFromDom(tree) 520 histograms, had_errors = ExtractHistogramsFromDom(tree)
526 if had_errors: 521 if had_errors:
527 logging.error('Error parsing %s', filename) 522 logging.error('Error parsing %s', filename)
528 raise Error() 523 raise Error()
529 return histograms 524 return histograms
530 525
531 526
532 def ExtractNames(histograms): 527 def ExtractNames(histograms):
533 return sorted(histograms.keys()) 528 return sorted(histograms.keys())
OLDNEW
« no previous file with comments | « tools/metrics/histograms/enums.xml ('k') | tools/metrics/histograms/print_style.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698