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
5import os
6import sys
7
8def _JoinPath(*path_parts):
9  return os.path.abspath(os.path.join(*path_parts))
10
11
12def _AddDirToPythonPath(*path_parts):
13  path = _JoinPath(*path_parts)
14  if os.path.isdir(path) and path not in sys.path:
15    # Some call sites that use Telemetry assume that sys.path[0] is the
16    # directory containing the script, so we add these extra paths to right
17    # after sys.path[0].
18    sys.path.insert(1, path)
19
20_CATAPULT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)),
21                             os.path.pardir, os.path.pardir, os.path.pardir)
22
23_AddDirToPythonPath(_CATAPULT_DIR, 'common', 'battor')
24