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
|