[Android] Implement 3-way sensor fallback for Device Orientation.
[chromium-blink-merge.git] / tools / metrics / common / path_util.py
blob11c1b15624825914a00d0777b167b20aa54c565d
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.
5 """Utility functions for resolving file paths in histograms scripts."""
7 import os.path
10 def GetHistogramsFile():
11 """Returns the path to histograms.xml.
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')
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)