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

Side by Side Diff: trunk/src/tools/metrics/histograms/update_extension_functions.py

Issue 188793003: Revert 255357 "Change the user action file format from .txt to ...." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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 """Updates ExtensionFunctions enum in histograms.xml file with values read from 5 """Updates ExtensionFunctions enum in histograms.xml file with values read from
6 extension_function_histogram_value.h. 6 extension_function_histogram_value.h.
7 7
8 If the file was pretty-printed, the updated version is pretty-printed too. 8 If the file was pretty-printed, the updated version is pretty-printed too.
9 """ 9 """
10 10
11 import logging 11 import logging
12 import re 12 import re
13 import sys 13 import sys
14 14
15 from xml.dom import minidom 15 from xml.dom import minidom
16 import print_style
17 16
18 # Import the metrics/common module. 17 from diffutil import PromptUserToAcceptDiff
19 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) 18 from pretty_print import PrettyPrintNode
20 from diff_util import PromptUserToAcceptDiff
21 19
22 HISTOGRAMS_PATH = 'histograms.xml' 20 HISTOGRAMS_PATH = 'histograms.xml'
23 ENUM_NAME = 'ExtensionFunctions' 21 ENUM_NAME = 'ExtensionFunctions'
24 22
25 EXTENSION_FUNCTIONS_HISTOGRAM_VALUE_PATH = \ 23 EXTENSION_FUNCTIONS_HISTOGRAM_VALUE_PATH = \
26 '../../../extensions/browser/extension_function_histogram_value.h' 24 '../../../extensions/browser/extension_function_histogram_value.h'
27 ENUM_START_MARKER = "^enum HistogramValue {" 25 ENUM_START_MARKER = "^enum HistogramValue {"
28 ENUM_END_MARKER = "^ENUM_BOUNDARY" 26 ENUM_END_MARKER = "^ENUM_BOUNDARY"
29 27
30 28
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 Log('Reading existing histograms from "%s".' % (HISTOGRAMS_PATH)) 129 Log('Reading existing histograms from "%s".' % (HISTOGRAMS_PATH))
132 with open(HISTOGRAMS_PATH, 'rb') as f: 130 with open(HISTOGRAMS_PATH, 'rb') as f:
133 histograms_doc = minidom.parse(f) 131 histograms_doc = minidom.parse(f)
134 f.seek(0) 132 f.seek(0)
135 xml = f.read() 133 xml = f.read()
136 134
137 Log('Comparing histograms enum with new enum definition.') 135 Log('Comparing histograms enum with new enum definition.')
138 UpdateHistogramDefinitions(histogram_values, histograms_doc) 136 UpdateHistogramDefinitions(histogram_values, histograms_doc)
139 137
140 Log('Writing out new histograms file.') 138 Log('Writing out new histograms file.')
141 new_xml = print_style.GetPrintStyle().PrettyPrintNode(histograms_doc) 139 new_xml = PrettyPrintNode(histograms_doc)
142
143 if PromptUserToAcceptDiff(xml, new_xml, 'Is the updated version acceptable?'): 140 if PromptUserToAcceptDiff(xml, new_xml, 'Is the updated version acceptable?'):
144 with open(HISTOGRAMS_PATH, 'wb') as f: 141 with open(HISTOGRAMS_PATH, 'wb') as f:
145 f.write(new_xml) 142 f.write(new_xml)
146 143
147 Log('Done.') 144 Log('Done.')
148 145
149 146
150 if __name__ == '__main__': 147 if __name__ == '__main__':
151 main() 148 main()
OLDNEW
« no previous file with comments | « trunk/src/tools/metrics/histograms/print_style.py ('k') | trunk/src/tools/metrics/histograms/update_policies.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698