pre-upload: tweak sys.path patching style a bit
This should make the scope here a bit more clear.
BUG=chromium:1003955
TEST=unittests still pass
Change-Id: Idbf76bdf77beb5760e6795c80dbef3ce949ccb8b
Reviewed-on: https://chromium-review.googlesource.com/1816124
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Will Bradley <wbbradley@chromium.org>
diff --git a/pre-upload.py b/pre-upload.py
index 59a6d67..6551d1b 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -28,18 +28,18 @@
from errors import (VerifyException, HookFailure, PrintErrorForProject,
PrintErrorsForCommit)
-# If repo imports us, the __name__ will be __builtin__, and the cwd will be in
-# the top level of the checkout (i.e. $CHROMEOS_CHECKOUT). chromite will be in
-# that directory, so add it to our path. This works whether we're running the
-# repo in $CHROMEOS_CHECKOUT/.repo/repo/ or a custom version in a completely
-# different tree.
-# TODO(vapier): Python 2 used "__builtin__" while Python 3 uses "builtins".
if __name__ in ('__builtin__', 'builtins'):
+ # If repo imports us, the __name__ will be __builtin__, and the cwd will be in
+ # the top level of the checkout (i.e. $CHROMEOS_CHECKOUT). chromite will be
+ # in that directory, so add it to our path. This works whether we're running
+ # the repo in $CHROMEOS_CHECKOUT/.repo/repo/ or a custom version in a
+ # completely different tree.
+ # TODO(vapier): Python 2 used "__builtin__" while Python 3 uses "builtins".
sys.path.insert(0, os.getcwd())
-# If we're run directly, we'll find chromite relative to the repohooks dir in
-# $CHROMEOS_CHECKOUT/src/repohooks, so go up two dirs.
-if __name__ == '__main__':
+elif __name__ == '__main__':
+ # If we're run directly, we'll find chromite relative to the repohooks dir in
+ # $CHROMEOS_CHECKOUT/src/repohooks, so go up two dirs.
sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), '..', '..'))
# The sys.path monkey patching confuses the linter.