Commit 603722e4 authored by Robert Ma's avatar Robert Ma Committed by Commit Bot

[blinkpy] Prepending to sys.path instead of appending

This is a code-health cleanup following discussions in
https://crrev.com/c/1462139/13/chrome/test/chromedriver/test/run_webdriver_tests.py#30

This is a mechanical substitution in blinkpy excluding third_party.

Change-Id: Ib546bb5fea743484186f62fd6fc1ea561700d610
Reviewed-on: https://chromium-review.googlesource.com/c/1473845Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Robert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#632380}
parent 703112f9
...@@ -35,19 +35,19 @@ from blinkpy.common.memoized import memoized ...@@ -35,19 +35,19 @@ from blinkpy.common.memoized import memoized
def add_typ_dir_to_sys_path(): def add_typ_dir_to_sys_path():
path_to_typ = get_typ_dir() path_to_typ = get_typ_dir()
if path_to_typ not in sys.path: if path_to_typ not in sys.path:
sys.path.append(path_to_typ) sys.path.insert(0, path_to_typ)
def add_bindings_scripts_dir_to_sys_path(): def add_bindings_scripts_dir_to_sys_path():
path_to_bindings_scripts = get_bindings_scripts_dir() path_to_bindings_scripts = get_bindings_scripts_dir()
if path_to_bindings_scripts not in sys.path: if path_to_bindings_scripts not in sys.path:
sys.path.append(path_to_bindings_scripts) sys.path.insert(0, path_to_bindings_scripts)
def add_blinkpy_thirdparty_dir_to_sys_path(): def add_blinkpy_thirdparty_dir_to_sys_path():
path = get_blinkpy_thirdparty_dir() path = get_blinkpy_thirdparty_dir()
if path not in sys.path: if path not in sys.path:
sys.path.append(path) sys.path.insert(0, path)
def add_depot_tools_dir_to_os_path(): def add_depot_tools_dir_to_os_path():
...@@ -92,7 +92,7 @@ def get_blink_tools_dir(): ...@@ -92,7 +92,7 @@ def get_blink_tools_dir():
def add_blink_tools_dir_to_sys_path(): def add_blink_tools_dir_to_sys_path():
path = get_blink_tools_dir() path = get_blink_tools_dir()
if path not in sys.path: if path not in sys.path:
sys.path.append(path) sys.path.insert(0, path)
def _does_blink_web_tests_exist(): def _does_blink_web_tests_exist():
......
...@@ -36,7 +36,7 @@ import unittest ...@@ -36,7 +36,7 @@ import unittest
# ensure that blink/tools is in sys.path for the next imports to work correctly. # ensure that blink/tools is in sys.path for the next imports to work correctly.
script_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) script_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
if script_dir not in sys.path: if script_dir not in sys.path:
sys.path.append(script_dir) sys.path.insert(0, script_dir)
from blinkpy.common.system.executive import Executive, ScriptError from blinkpy.common.system.executive import Executive, ScriptError
......
...@@ -12,7 +12,7 @@ from blinkpy.web_tests.controllers import web_test_finder ...@@ -12,7 +12,7 @@ from blinkpy.web_tests.controllers import web_test_finder
_MOCK_ROOT = os.path.join( _MOCK_ROOT = os.path.join(
path_finder.get_chromium_src_dir(), 'third_party', 'pymock') path_finder.get_chromium_src_dir(), 'third_party', 'pymock')
sys.path.append(_MOCK_ROOT) sys.path.insert(0, _MOCK_ROOT)
import mock import mock
......
...@@ -43,13 +43,13 @@ from blinkpy.web_tests.port import port_testcase ...@@ -43,13 +43,13 @@ from blinkpy.web_tests.port import port_testcase
_DEVIL_ROOT = os.path.join( _DEVIL_ROOT = os.path.join(
get_chromium_src_dir(), 'third_party', 'catapult', 'devil') get_chromium_src_dir(), 'third_party', 'catapult', 'devil')
sys.path.append(_DEVIL_ROOT) sys.path.insert(0, _DEVIL_ROOT)
from devil.android import device_utils from devil.android import device_utils
from devil.android.sdk import adb_wrapper from devil.android.sdk import adb_wrapper
_MOCK_ROOT = os.path.join( _MOCK_ROOT = os.path.join(
get_chromium_src_dir(), 'third_party', 'pymock') get_chromium_src_dir(), 'third_party', 'pymock')
sys.path.append(_MOCK_ROOT) sys.path.insert(0, _MOCK_ROOT)
import mock import mock
......
...@@ -45,7 +45,7 @@ import types ...@@ -45,7 +45,7 @@ import types
# that blink/tools is in sys.path for the next imports to work correctly. # that blink/tools is in sys.path for the next imports to work correctly.
tools_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) tools_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
if tools_dir not in sys.path: if tools_dir not in sys.path:
sys.path.append(tools_dir) sys.path.insert(0, tools_dir)
from blinkpy.common import exit_codes from blinkpy.common import exit_codes
from blinkpy.common import read_checksum_from_png from blinkpy.common import read_checksum_from_png
......
...@@ -51,7 +51,7 @@ from blinkpy.web_tests.views.printing import Printer ...@@ -51,7 +51,7 @@ from blinkpy.web_tests.views.printing import Printer
_MOCK_ROOT = os.path.join( _MOCK_ROOT = os.path.join(
path_finder.get_chromium_src_dir(), 'third_party', 'pymock') path_finder.get_chromium_src_dir(), 'third_party', 'pymock')
sys.path.append(_MOCK_ROOT) sys.path.insert(0, _MOCK_ROOT)
import mock import mock
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment