OLD | NEW |
---|---|
(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) | |
OLD | NEW |