OLD | NEW |
(Empty) | |
| 1 # Copyright 2016 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 import contextlib |
| 6 import os |
| 7 import sys |
| 8 |
| 9 DIR_SOURCE_ROOT = os.environ.get( |
| 10 'CHECKOUT_SOURCE_ROOT', |
| 11 os.path.abspath(os.path.join(os.path.dirname(__file__), |
| 12 os.pardir, os.pardir, os.pardir, os.pardir))) |
| 13 |
| 14 BUILD_COMMON_PATH = os.path.join( |
| 15 DIR_SOURCE_ROOT, 'build', 'util', 'lib', 'common') |
| 16 |
| 17 # third-party libraries |
| 18 ANDROID_PLATFORM_DEVELOPMENT_SCRIPTS_PATH = os.path.join( |
| 19 DIR_SOURCE_ROOT, 'third_party', 'android_platform', 'development', |
| 20 'scripts') |
| 21 DEVIL_PATH = os.path.join( |
| 22 DIR_SOURCE_ROOT, 'third_party', 'catapult', 'devil') |
| 23 PYMOCK_PATH = os.path.join( |
| 24 DIR_SOURCE_ROOT, 'third_party', 'pymock') |
| 25 |
| 26 @contextlib.contextmanager |
| 27 def SysPath(path, position=None): |
| 28 if position is None: |
| 29 sys.path.append(path) |
| 30 else: |
| 31 sys.path.insert(position, path) |
| 32 try: |
| 33 yield |
| 34 finally: |
| 35 if sys.path[-1] == path: |
| 36 sys.path.pop() |
| 37 else: |
| 38 sys.path.remove(path) |
OLD | NEW |