summaryrefslogtreecommitdiffstats
path: root/subcmds/sync.py
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2013-05-17 10:49:33 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2013-05-23 07:28:53 +0000
commit59bbb580e34bbc5dce76dacaad9ff94f21fa396f (patch)
tree4d19216215edc174851baa10a00a3bccba9d4e45 /subcmds/sync.py
parentda45e5d8848246cddbce80ff56786bd7330ba5af (diff)
downloadgit-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/sync.py')
-rw-r--r--subcmds/sync.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 8fb94885..b34787d2 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -24,22 +24,17 @@ import socket
24import subprocess 24import subprocess
25import sys 25import sys
26import time 26import time
27try: 27
28 # For python3 28from pyversion import is_python3
29if is_python3():
29 import urllib.parse 30 import urllib.parse
30except ImportError: 31 import xmlrpc.client
31 # For python2 32else:
32 import imp 33 import imp
33 import urlparse 34 import urlparse
35 import xmlrpclib
34 urllib = imp.new_module('urllib') 36 urllib = imp.new_module('urllib')
35 urllib.parse = urlparse 37 urllib.parse = urlparse
36try:
37 # For python3
38 import xmlrpc.client
39except ImportError:
40 # For python2
41 import imp
42 import xmlrpclib
43 xmlrpc = imp.new_module('xmlrpc') 38 xmlrpc = imp.new_module('xmlrpc')
44 xmlrpc.client = xmlrpclib 39 xmlrpc.client = xmlrpclib
45 40