OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 enums in histograms.xml file with values read from provided C++ enum. | 5 """Updates enums in histograms.xml file with values read from provided C++ enum. |
6 | 6 |
7 If the file was pretty-printed, the updated version is pretty-printed too. | 7 If the file was pretty-printed, the updated version is pretty-printed too. |
8 """ | 8 """ |
9 | 9 |
10 import logging | 10 import logging |
| 11 import os |
11 import print_style | 12 import print_style |
12 import re | 13 import re |
13 import sys | 14 import sys |
14 | 15 |
15 from xml.dom import minidom | 16 from xml.dom import minidom |
16 from diffutil import PromptUserToAcceptDiff | 17 |
| 18 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) |
| 19 from diff_util import PromptUserToAcceptDiff |
17 | 20 |
18 class UserError(Exception): | 21 class UserError(Exception): |
19 def __init__(self, message): | 22 def __init__(self, message): |
20 Exception.__init__(self, message) | 23 Exception.__init__(self, message) |
21 | 24 |
22 @property | 25 @property |
23 def message(self): | 26 def message(self): |
24 return self.args[0] | 27 return self.args[0] |
25 | 28 |
26 | 29 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 UpdateHistogramDefinitions(histogram_enum_name, source_enum_values, | 130 UpdateHistogramDefinitions(histogram_enum_name, source_enum_values, |
128 source_enum_path, histograms_doc) | 131 source_enum_path, histograms_doc) |
129 | 132 |
130 Log('Writing out new histograms file.') | 133 Log('Writing out new histograms file.') |
131 new_xml = print_style.GetPrintStyle().PrettyPrintNode(histograms_doc) | 134 new_xml = print_style.GetPrintStyle().PrettyPrintNode(histograms_doc) |
132 if PromptUserToAcceptDiff(xml, new_xml, 'Is the updated version acceptable?'): | 135 if PromptUserToAcceptDiff(xml, new_xml, 'Is the updated version acceptable?'): |
133 with open(HISTOGRAMS_PATH, 'wb') as f: | 136 with open(HISTOGRAMS_PATH, 'wb') as f: |
134 f.write(new_xml) | 137 f.write(new_xml) |
135 | 138 |
136 Log('Done.') | 139 Log('Done.') |
OLD | NEW |