external: fix import errors for python2
remove duplicate import urllib.parse which is handled below
with try and except no need to import separately. Also, change
the way to get the python version.
Signed-off-by: subhamkrai <srai@redhat.com>
(cherry picked from commit 9a952df419)
This commit is contained in:
1 parent
8e5435f977
commit
71bf886dab
1 file changed
+5
-6
@@ -25,11 +25,14 @@ from hashlib import sha1 as sha
|
||||
from os import linesep as LINESEP
|
||||
from os import path
|
||||
from email.utils import formatdate
|
||||
import urllib.parse
|
||||
|
||||
import requests
|
||||
from requests.auth import AuthBase
|
||||
|
||||
py3k = False
|
||||
if sys.version_info.major >= 3:
|
||||
py3k = True
|
||||
import urllib.parse
|
||||
|
||||
ModuleNotFoundError = ImportError
|
||||
|
||||
try:
|
||||
@@ -58,13 +61,9 @@ except ModuleNotFoundError:
|
||||
# for 3.x
|
||||
from urllib.parse import urlparse
|
||||
|
||||
py3k = False
|
||||
try:
|
||||
from urlparse import urlparse
|
||||
from base64 import encodestring
|
||||
except:
|
||||
py3k = True
|
||||
from urllib.parse import urlparse
|
||||
from base64 import encodebytes as encodestring
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user