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
4 # found in the LICENSE file.
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
8 snippet to put in uma.py of Chromium Dashboard. Make sure that you review the
9 output for correctness.
16 from update_histogram_enum
import ReadHistogramValues
17 from update_histogram_enum
import UpdateHistogramEnum
20 def PrintEnumForDashboard(enum_dict
):
21 """Prints enum_items formatted for use in uma.py of Chromium dashboard."""
22 for key
in sorted(enum_dict
.iterkeys()):
23 print ' %d: \'%s\',' % (key
, enum_dict
[key
])
26 if __name__
== '__main__':
27 parser
= optparse
.OptionParser()
28 parser
.add_option('--for-dashboard', action
='store_true', dest
='dashboard',
30 help='Print enum definition formatted for use in uma.py of '
31 'Chromium dashboard developed at '
32 'https://github.com/GoogleChrome/chromium-dashboard')
33 options
, args
= parser
.parse_args()
35 source_path
= 'third_party/WebKit/Source/core/frame/UseCounter.h'
37 START_MARKER
= '^enum Feature {'
38 END_MARKER
= '^NumberOfFeatures'
41 enum_dict
= ReadHistogramValues(source_path
, START_MARKER
, END_MARKER
)
42 PrintEnumForDashboard(enum_dict
)
45 histogram_enum_name
='FeatureObserver',
46 source_enum_path
=source_path
,
47 start_marker
=START_MARKER
,
48 end_marker
=END_MARKER
)