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

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

Issue 1143323006: Histograms.xml python script housekeeping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bad_message
Patch Set: Fix imports (sadface) Created 5 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Scans the Chromium source of UseCounter, formats the Feature enum for 6 """Scans the Chromium source of UseCounter, formats the Feature enum for
7 histograms.xml and merges it. This script can also generate a python code 7 histograms.xml and merges it. This script can also generate a python code
8 snippet to put in uma.py of Chromium Dashboard. Make sure that you review the 8 snippet to put in uma.py of Chromium Dashboard. Make sure that you review the
9 output for correctness. 9 output for correctness.
10 """ 10 """
11 11
12 import optparse 12 import optparse
13 import os 13 import os
14 import sys 14 import sys
15 15
16 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common'))
17 from update_histogram_enum import ReadHistogramValues 16 from update_histogram_enum import ReadHistogramValues
18 from update_histogram_enum import UpdateHistogramEnum 17 from update_histogram_enum import UpdateHistogramEnum
19 18
20 19
21 def PrintEnumForDashboard(enum_dict): 20 def PrintEnumForDashboard(enum_dict):
22 """Prints enum_items formatted for use in uma.py of Chromium dashboard.""" 21 """Prints enum_items formatted for use in uma.py of Chromium dashboard."""
23 for key in sorted(enum_dict.iterkeys()): 22 for key in sorted(enum_dict.iterkeys()):
24 print ' %d: \'%s\',' % (key, enum_dict[key]) 23 print ' %d: \'%s\',' % (key, enum_dict[key])
25 24
26 25
27 if __name__ == '__main__': 26 if __name__ == '__main__':
28 parser = optparse.OptionParser() 27 parser = optparse.OptionParser()
29 parser.add_option('--for-dashboard', action='store_true', dest='dashboard', 28 parser.add_option('--for-dashboard', action='store_true', dest='dashboard',
30 default=False, 29 default=False,
31 help='Print enum definition formatted for use in uma.py of ' 30 help='Print enum definition formatted for use in uma.py of '
32 'Chromium dashboard developed at ' 31 'Chromium dashboard developed at '
33 'https://github.com/GoogleChrome/chromium-dashboard') 32 'https://github.com/GoogleChrome/chromium-dashboard')
34 options, args = parser.parse_args() 33 options, args = parser.parse_args()
35 34
36 source_path = \ 35 source_path = 'third_party/WebKit/Source/core/frame/UseCounter.h'
37 '../../../third_party/WebKit/Source/core/frame/UseCounter.h'
38 36
39 START_MARKER = '^enum Feature {' 37 START_MARKER = '^enum Feature {'
40 END_MARKER = '^NumberOfFeatures' 38 END_MARKER = '^NumberOfFeatures'
41 39
42 if options.dashboard: 40 if options.dashboard:
43 enum_dict = ReadHistogramValues(source_path, START_MARKER, END_MARKER) 41 enum_dict = ReadHistogramValues(source_path, START_MARKER, END_MARKER)
44 PrintEnumForDashboard(enum_dict) 42 PrintEnumForDashboard(enum_dict)
45 else: 43 else:
46 UpdateHistogramEnum( 44 UpdateHistogramEnum(
47 histogram_enum_name='FeatureObserver', 45 histogram_enum_name='FeatureObserver',
48 source_enum_path=source_path, 46 source_enum_path=source_path,
49 start_marker=START_MARKER, 47 start_marker=START_MARKER,
50 end_marker=END_MARKER) 48 end_marker=END_MARKER)
OLDNEW
« no previous file with comments | « tools/metrics/histograms/update_use_counter_css.py ('k') | tools/metrics/histograms/validate_format.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698