diff options
author | David Pursehouse <david.pursehouse@sonymobile.com> | 2013-05-17 10:49:33 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2013-05-23 07:28:53 +0000 |
commit | 59bbb580e34bbc5dce76dacaad9ff94f21fa396f (patch) | |
tree | 4d19216215edc174851baa10a00a3bccba9d4e45 /subcmds/upload.py | |
parent | da45e5d8848246cddbce80ff56786bd7330ba5af (diff) | |
download | git-repo-59bbb580e34bbc5dce76dacaad9ff94f21fa396f.tar.gz |
Move Python version checking to a separate module
Add a new module with methods for checking the Python version.
Instead of handling Python3 imports with try...except blocks, first
check the python version and then import the relevant modules. This
makes the code a bit cleaner and will result in less diff when/if we
remove support for Python < 3 later.
Use the same mechanism to handle `input` vs. `raw_input` and add
suppression of pylint warnings caused by redefinition of the built-in
method `input`.
Change-Id: Ia403e525b88d77640a741ac50382146e7d635924
Also-by: Chirayu Desai <cdesai@cyanogenmod.org>
Signed-off-by: Chirayu Desai <cdesai@cyanogenmod.org>
Diffstat (limited to 'subcmds/upload.py')
-rw-r--r-- | subcmds/upload.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/subcmds/upload.py b/subcmds/upload.py index a34938e5..13b87784 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
@@ -23,10 +23,11 @@ from editor import Editor | |||
23 | from error import HookError, UploadError | 23 | from error import HookError, UploadError |
24 | from project import RepoHook | 24 | from project import RepoHook |
25 | 25 | ||
26 | try: | 26 | from pyversion import is_python3 |
27 | if not is_python3(): | ||
28 | # pylint:disable=W0622 | ||
27 | input = raw_input | 29 | input = raw_input |
28 | except NameError: | 30 | # pylint:enable=W0622 |
29 | pass | ||
30 | 31 | ||
31 | UNUSUAL_COMMIT_THRESHOLD = 5 | 32 | UNUSUAL_COMMIT_THRESHOLD = 5 |
32 | 33 | ||