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

Unified Diff: tools/metrics/histograms/update_histogram_enum.py

Issue 276663002: Script to populate the XML for the CSS property UseCounter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@update-css-histogram
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: tools/metrics/histograms/update_histogram_enum.py
diff --git a/tools/metrics/histograms/update_histogram_enum.py b/tools/metrics/histograms/update_histogram_enum.py
index 03acea78e3ce9af32b8383fbba3526da4ac96ff3..82936fa43372bc0fcdb88ddb43bbde31d680269d 100644
--- a/tools/metrics/histograms/update_histogram_enum.py
+++ b/tools/metrics/histograms/update_histogram_enum.py
@@ -136,20 +136,15 @@ def UpdateHistogramDefinitions(histogram_enum_name, source_enum_values,
enum_node.appendChild(child)
-def UpdateHistogramEnum(histogram_enum_name, source_enum_path,
- start_marker, end_marker):
+def UpdateHistogramFromDict(histogram_enum_name, source_enum_values,
+ source_enum_path):
"""Updates |histogram_enum_name| enum in histograms.xml file with values
- read from |source_enum_path|, where |start_marker| and |end_marker| indicate
- the beginning and end of the source enum definition, respectively.
+ from the {value: 'key'} dictionary |source_enum_values|
"""
# TODO(ahernandez.miralles): The line below is present in nearly every
# file in this directory; factor out into a central location
HISTOGRAMS_PATH = 'histograms.xml'
- Log('Reading histogram enum definition from "{0}".'.format(source_enum_path))
- source_enum_values = ReadHistogramValues(source_enum_path, start_marker,
- end_marker)
-
Log('Reading existing histograms from "{0}".'.format(HISTOGRAMS_PATH))
with open(HISTOGRAMS_PATH, 'rb') as f:
histograms_doc = minidom.parse(f)
@@ -171,3 +166,18 @@ def UpdateHistogramEnum(histogram_enum_name, source_enum_path,
f.write(new_xml)
Log('Done.')
+
+
+def UpdateHistogramEnum(histogram_enum_name, source_enum_path,
+ start_marker, end_marker):
+ """Updates |histogram_enum_name| enum in histograms.xml file with values
+ read from |source_enum_path|, where |start_marker| and |end_marker| indicate
+ the beginning and end of the source enum definition, respectively.
+ """
+
+ Log('Reading histogram enum definition from "{0}".'.format(source_enum_path))
+ source_enum_values = ReadHistogramValues(source_enum_path, start_marker,
+ end_marker)
+
+ UpdateHistogramFromDict(histogram_enum_name, source_enum_values,
+ source_enum_path)
tyoshino (SeeGerritForStatus) 2014/05/08 08:06:53 4 space indent plz http://google-styleguide.googl
Mike Lawther (Google) 2014/05/09 01:11:03 Done.

Powered by Google App Engine
This is Rietveld 408576698