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

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

Issue 1094873002: Extensions: Switch to new permission message system, part V (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 7 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
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 """Updates enums in histograms.xml file with values read from provided C++ enum. 5 """Updates enums in histograms.xml file with values read from provided C++ enum.
6 6
7 If the file was pretty-printed, the updated version is pretty-printed too. 7 If the file was pretty-printed, the updated version is pretty-printed too.
8 """ 8 """
9 9
10 import logging 10 import logging
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 return item_node 82 return item_node
83 83
84 84
85 def UpdateHistogramDefinitions(histogram_enum_name, source_enum_values, 85 def UpdateHistogramDefinitions(histogram_enum_name, source_enum_values,
86 source_enum_path, document): 86 source_enum_path, document):
87 """Updates the enum node named |histogram_enum_name| based on the definition 87 """Updates the enum node named |histogram_enum_name| based on the definition
88 stored in |source_enum_values|. Existing items for which |source_enum_values| 88 stored in |source_enum_values|. Existing items for which |source_enum_values|
89 doesn't contain any corresponding data will be preserved. |source_enum_path| 89 doesn't contain any corresponding data will be preserved. |source_enum_path|
90 will be used to insert a comment. 90 will be used to insert a comment.
91 """ 91 """
92 # Get a dom of <enum name=|name| ...> node in |document|. 92 # Get a dom of <enum name=|histogram_enum_name| ...> node in |document|.
93 for enum_node in document.getElementsByTagName('enum'): 93 for enum_node in document.getElementsByTagName('enum'):
94 if enum_node.attributes['name'].value == histogram_enum_name: 94 if enum_node.attributes['name'].value == histogram_enum_name:
95 break 95 break
96 else: 96 else:
97 raise UserError('No {0} enum node found'.format(name)) 97 raise UserError('No {0} enum node found'.format(histogram_enum_name))
98 98
99 new_item_nodes = {} 99 new_item_nodes = {}
100 new_comments = [] 100 new_comments = []
101 101
102 # Add a "Generated from (...)" comment. 102 # Add a "Generated from (...)" comment.
103 new_comments.append( 103 new_comments.append(
104 document.createComment(' Generated from {0} '.format(source_enum_path))) 104 document.createComment(' Generated from {0} '.format(source_enum_path)))
105 105
106 # Create item nodes for each of the enum values. 106 # Create item nodes for each of the enum values.
107 for value, label in source_enum_values.iteritems(): 107 for value, label in source_enum_values.iteritems():
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 read from |source_enum_path|, where |start_marker| and |end_marker| indicate 176 read from |source_enum_path|, where |start_marker| and |end_marker| indicate
177 the beginning and end of the source enum definition, respectively. 177 the beginning and end of the source enum definition, respectively.
178 """ 178 """
179 179
180 Log('Reading histogram enum definition from "{0}".'.format(source_enum_path)) 180 Log('Reading histogram enum definition from "{0}".'.format(source_enum_path))
181 source_enum_values = ReadHistogramValues(source_enum_path, start_marker, 181 source_enum_values = ReadHistogramValues(source_enum_path, start_marker,
182 end_marker) 182 end_marker)
183 183
184 UpdateHistogramFromDict(histogram_enum_name, source_enum_values, 184 UpdateHistogramFromDict(histogram_enum_name, source_enum_values,
185 source_enum_path) 185 source_enum_path)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698