Chromium Code Reviews| Index: tools/metrics/histograms/update_editor_commands.py |
| diff --git a/tools/metrics/histograms/update_editor_commands.py b/tools/metrics/histograms/update_editor_commands.py |
| index 1afdf02775d593bfaaca88d03f6848b0ce67dcc0..50d763ce51ac509bec5fb9ecf40a33f96942142f 100644 |
| --- a/tools/metrics/histograms/update_editor_commands.py |
| +++ b/tools/metrics/histograms/update_editor_commands.py |
| @@ -15,18 +15,17 @@ import sys |
| from xml.dom import minidom |
| -from diffutil import PromptUserToAcceptDiff |
| import print_style |
| +import histograms_path |
|
Ilya Sherman
2015/05/27 00:12:24
nit: Alphabetize?
ncarter (slow)
2015/05/29 23:01:10
Done.
|
| # Import the metrics/common module. |
| sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) |
| from diff_util import PromptUserToAcceptDiff |
| -HISTOGRAMS_PATH = 'histograms.xml' |
| +HISTOGRAMS_PATH = histograms_path.GetHistogramsFile() |
| ENUM_NAME = 'MappedEditingCommands' |
| -EXTENSION_FUNCTIONS_HISTOGRAM_VALUE_PATH = \ |
| - '../../../third_party/WebKit/Source/core/editing/EditorCommand.cpp' |
| +EDITOR_COMMAND_CPP = 'third_party/WebKit/Source/core/editing/EditorCommand.cpp' |
| ENUM_START_MARKER = "^ static const CommandEntry commands\[\] = {" |
| ENUM_END_MARKER = "^ };" |
| @@ -48,7 +47,7 @@ def ReadHistogramValues(filename): |
| """ |
| # Read the file as a list of lines |
| - with open(filename) as f: |
| + with open(histograms_path.GetInputFile(filename)) as f: |
| content = f.readlines() |
| # Locate the enum definition and collect all entries in it |
| @@ -97,8 +96,7 @@ def UpdateHistogramDefinitions(histogram_values, document): |
| extension_functions_enum_node.lastChild) |
| # Add a "Generated from (...)" comment |
| - comment = ' Generated from {0} '.format( |
| - EXTENSION_FUNCTIONS_HISTOGRAM_VALUE_PATH) |
| + comment = ' Generated from {0} '.format(EDITOR_COMMAND_CPP) |
| extension_functions_enum_node.appendChild(document.createComment(comment)) |
| # Add values generated from policy templates. |
| @@ -117,10 +115,8 @@ def main(): |
| sys.stderr.write(__doc__) |
| sys.exit(1) |
| - Log('Reading histogram enum definition from "%s".' |
| - % (EXTENSION_FUNCTIONS_HISTOGRAM_VALUE_PATH)) |
| - histogram_values = ReadHistogramValues( |
| - EXTENSION_FUNCTIONS_HISTOGRAM_VALUE_PATH) |
| + Log('Reading histogram enum definition from "%s".' % EDITOR_COMMAND_CPP) |
| + histogram_values = ReadHistogramValues(EDITOR_COMMAND_CPP) |
| Log('Reading existing histograms from "%s".' % (HISTOGRAMS_PATH)) |
| with open(HISTOGRAMS_PATH, 'rb') as f: |