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

Unified Diff: tools/metrics/common/path_util.py

Issue 1143323006: Histograms.xml python script housekeeping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bad_message
Patch Set: Fix imports (sadface) 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
« no previous file with comments | « extensions/browser/bad_message.h ('k') | tools/metrics/common/presubmit_util.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/metrics/common/path_util.py
diff --git a/tools/metrics/common/path_util.py b/tools/metrics/common/path_util.py
new file mode 100644
index 0000000000000000000000000000000000000000..99f1cfef414025b361d0daa45bf575bc75ec08ba
--- /dev/null
+++ b/tools/metrics/common/path_util.py
@@ -0,0 +1,23 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# 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 GetInputFile('tools/metrics/histograms/histograms.xml')
+
+
+def GetInputFile(src_relative_file_path):
+ """Converts a src/-relative file path into a path that can be opened."""
+ depth = [os.path.dirname(__file__), '..', '..', '..']
+ path = os.path.join(*(depth + src_relative_file_path.split('/')))
+ return os.path.abspath(path)
« no previous file with comments | « extensions/browser/bad_message.h ('k') | tools/metrics/common/presubmit_util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698