OLD | NEW |
(Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 """Utility functions for resolving file paths in histograms scripts.""" |
| 6 |
| 7 import os.path |
| 8 |
| 9 |
| 10 def GetHistogramsFile(): |
| 11 """Returns the path to histograms.xml. |
| 12 |
| 13 Prefer using this function instead of just open("histograms.xml"), so that |
| 14 scripts work properly even if run from outside the histograms directory. |
| 15 """ |
| 16 return GetInputFile('tools/metrics/histograms/histograms.xml') |
| 17 |
| 18 |
| 19 def GetInputFile(src_relative_file_path): |
| 20 """Converts a src/-relative file path into a path that can be opened.""" |
| 21 depth = [os.path.dirname(__file__), '..', '..', '..'] |
| 22 path = os.path.join(*(depth + src_relative_file_path.split('/'))) |
| 23 return os.path.abspath(path) |
OLD | NEW |