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

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

Issue 170233008: Add presubmit check and automatic update script for ExtensionPermission enum. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update directory name Created 6 years, 10 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
(Empty)
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
3 # found in the LICENSE file.
4
5 '''Updates ExtensionPermission enum in histograms.xml file with values read from
6 permission_message.h.
7
8 If the file was pretty-printed, the updated version is pretty-printed too.
9 '''
10
11 import re
12
13 from update_histogram_enum import UpdateHistogramEnum
14
15 def StyleLabel(label):
16 '''Transforms labels of form "kLabelName" to "LABEL_NAME"
Ilya Sherman 2014/03/10 22:21:54 Why is this transformation useful? Why not just u
ahernandez 2014/03/13 19:11:25 The ExtensionPermission enum already has it's entr
17 '''
18 uiIndex = label.find('UI')
19 pattern = '([A-Z])'
20
21 assert label.startswith('k') and label[1].isupper()
22
23 if uiIndex != -1 and label[uiIndex - 1].islower():
24 pattern = '([A-HJ-Z])'
Jeffrey Yasskin 2014/03/10 20:53:23 This looks flaky: Consider (and test!) "kUIWasIsol
25
26 return label[1] + re.sub(pattern, r'_\1', label[2:]).upper()
27
28 if __name__ == '__main__':
29 UpdateHistogramEnum(histogram_enum_name='ExtensionPermission',
30 source_enum_path=('../../../extensions/common/permissions'
Ilya Sherman 2014/03/10 22:21:54 Have you verified that the forward slashes work on
31 '/permission_message.h'),
Ilya Sherman 2014/03/10 22:21:54 nit: Why does this string start with a slash?
32 start_marker='^enum ID {',
33 end_marker='^kEnumBoundary',
34 labelTransformer=StyleLabel)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698