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

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

Issue 1143323006: Histograms.xml python script housekeeping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bad_message
Patch Set: Split off the extensions permission weirdness. Created 5 years, 7 months 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
Index: tools/metrics/histograms/histograms_path.py
diff --git a/tools/metrics/histograms/histograms_path.py b/tools/metrics/histograms/histograms_path.py
new file mode 100644
index 0000000000000000000000000000000000000000..e7c3bc3b6bda5ab7b43bfa9a14af36f40daf6b6a
--- /dev/null
+++ b/tools/metrics/histograms/histograms_path.py
@@ -0,0 +1,22 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
Ilya Sherman 2015/05/27 00:12:24 nit: 2015
ncarter (slow) 2015/05/29 23:01:10 Done.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Utility functions for resolving file paths in histograms scripts."""
+
+import os.path
+
+
+def GetHistogramsFile():
+ """Returns the path to histograms.xml.
+
+ Prefer using this function instead of just open("histograms.xml"), so that
+ scripts work properly even if run from outside the histograms directory.
+ """
+ return os.path.join(os.path.dirname(__file__), 'histograms.xml')
+
+
+def GetInputFile(src_relative_file_path):
Ilya Sherman 2015/05/27 00:12:24 Is it worth providing this at a higher level, so t
ncarter (slow) 2015/05/29 23:01:10 I moved it to common (as path_util.py). I also add
+ """Converts a src/-relative file path into a path that can be opened."""
+ depth = [os.path.dirname(__file__), '..', '..', '..']
+ return os.path.join(*(depth + src_relative_file_path.split('/')))
Ilya Sherman 2015/05/27 00:12:24 Out of curiousity, what does the "*" operator do?
ncarter (slow) 2015/05/29 23:01:10 https://docs.python.org/2/tutorial/controlflow.htm

Powered by Google App Engine
This is Rietveld 408576698