Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(725)

Unified Diff: tools/metrics/histograms/pretty_print.py

Issue 121403002: Have pretty_print.py find histograms.xml. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remediate Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698