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 /manifest_xml.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 'manifest_xml.py')
-rw-r--r-- | manifest_xml.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index cc441dc8..16476aa5 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
@@ -18,16 +18,16 @@ import itertools | |||
18 | import os | 18 | import os |
19 | import re | 19 | import re |
20 | import sys | 20 | import sys |
21 | try: | 21 | import xml.dom.minidom |
22 | # For python3 | 22 | |
23 | from pyversion import is_python3 | ||
24 | if is_python3(): | ||
23 | import urllib.parse | 25 | import urllib.parse |
24 | except ImportError: | 26 | else: |
25 | # For python2 | ||
26 | import imp | 27 | import imp |
27 | import urlparse | 28 | import urlparse |
28 | urllib = imp.new_module('urllib') | 29 | urllib = imp.new_module('urllib') |
29 | urllib.parse = urlparse | 30 | urllib.parse = urlparse |
30 | import xml.dom.minidom | ||
31 | 31 | ||
32 | from git_config import GitConfig | 32 | from git_config import GitConfig |
33 | from git_refs import R_HEADS, HEAD | 33 | from git_refs import R_HEADS, HEAD |