OLD | NEW |
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 EnterprisePolicies enum in histograms.xml file with policy | 5 """Updates EnterprisePolicies enum in histograms.xml file with policy |
6 definitions read from policy_templates.json. | 6 definitions read from policy_templates.json. |
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 re | 11 import re |
12 import sys | 12 import sys |
13 | 13 |
14 from ast import literal_eval | 14 from ast import literal_eval |
15 from optparse import OptionParser | 15 from optparse import OptionParser |
16 from xml.dom import minidom | 16 from xml.dom import minidom |
17 | 17 |
18 from diffutil import PromptUserToAcceptDiff | 18 from diffutil import PromptUserToAcceptDiff |
19 from pretty_print import PrettyPrintNode | 19 from pretty_print import PrettyPrintNode |
20 | 20 |
21 HISTOGRAMS_PATH = 'histograms.xml' | 21 HISTOGRAMS_PATH = 'histograms.xml' |
22 POLICY_TEMPLATES_PATH = '../../../chrome/app/policy/policy_templates.json' | 22 POLICY_TEMPLATES_PATH = |
| 23 '../../../components/policy/resources/policy_templates.json' |
23 ENUM_NAME = 'EnterprisePolicies' | 24 ENUM_NAME = 'EnterprisePolicies' |
24 | 25 |
25 class UserError(Exception): | 26 class UserError(Exception): |
26 def __init__(self, message): | 27 def __init__(self, message): |
27 Exception.__init__(self, message) | 28 Exception.__init__(self, message) |
28 | 29 |
29 @property | 30 @property |
30 def message(self): | 31 def message(self): |
31 return self.args[0] | 32 return self.args[0] |
32 | 33 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 with open(HISTOGRAMS_PATH, 'wb') as f: | 124 with open(HISTOGRAMS_PATH, 'wb') as f: |
124 f.write(new_xml) | 125 f.write(new_xml) |
125 | 126 |
126 | 127 |
127 if __name__ == '__main__': | 128 if __name__ == '__main__': |
128 try: | 129 try: |
129 main() | 130 main() |
130 except UserError as e: | 131 except UserError as e: |
131 print >>sys.stderr, e.message | 132 print >>sys.stderr, e.message |
132 sys.exit(1) | 133 sys.exit(1) |
OLD | NEW |