Chromium Code Reviews| Index: tools/metrics/histograms/pretty_print.py |
| diff --git a/tools/metrics/histograms/pretty_print.py b/tools/metrics/histograms/pretty_print.py |
| index f1001b1ce96c118f38a77c2ee386493366a94b2d..7857fcbcb5f3583914b1627b34890c90b2f1cd7f 100755 |
| --- a/tools/metrics/histograms/pretty_print.py |
| +++ b/tools/metrics/histograms/pretty_print.py |
| @@ -17,11 +17,14 @@ from __future__ import with_statement |
| import diffutil |
| import json |
| import logging |
| +import os |
| import shutil |
| import sys |
| import textwrap |
| import xml.dom.minidom |
| +sys.path.insert(1, os.path.join(sys.path[0], '..', '..', 'python')) |
|
Ilya Sherman
2013/12/27 21:48:05
Hmm, I hadn't noticed that this was needed to supp
|
| +from google import path_utils |
| WRAP_COLUMN = 80 |
| @@ -316,8 +319,10 @@ def main(): |
| presubmit = ('--presubmit' in sys.argv) |
| + script_dir = path_utils.ScriptDir() |
| + |
| logging.info('Loading histograms.xml...') |
| - with open('histograms.xml', 'rb') as f: |
| + with open(os.path.join(script_dir, 'histograms.xml'), 'rb') as f: |
| xml = f.read() |
| # Check there are no CR ('\r') characters in the file. |
| @@ -347,10 +352,11 @@ def main(): |
| return |
| logging.info('Creating backup file histograms.before.pretty-print.xml') |
| - shutil.move('histograms.xml', 'histograms.before.pretty-print.xml') |
| + shutil.move(os.path.join(script_dir, 'histograms.xml'), |
| + os.path.join(script_dir, 'histograms.before.pretty-print.xml')) |
|
Ilya Sherman
2013/12/27 21:48:05
nit: Please declare named constants for the file n
gavinp
2014/01/06 17:36:07
Done. I did this with automatic variables though i
Ilya Sherman
2014/01/06 23:22:36
This is fine, thanks.
|
| logging.info('Writing new histograms.xml file') |
| - with open('histograms.xml', 'wb') as f: |
| + with open(os.path.join(script_dir, 'histograms.xml'), 'wb') as f: |
| f.write(pretty) |