diff --git a/tools/repo_pull/gerrit.py b/tools/repo_pull/gerrit.py index 1fecafb55..1d63658ec 100755 --- a/tools/repo_pull/gerrit.py +++ b/tools/repo_pull/gerrit.py @@ -28,28 +28,23 @@ import sys import xml.dom.minidom try: - from urllib.error import HTTPError # PY3 -except ImportError: - from urllib2 import HTTPError # PY2 - -try: + # PY3 + from urllib.error import HTTPError + from urllib.parse import urlencode, urlparse from urllib.request import ( - HTTPBasicAuthHandler, Request, build_opener) # PY3 + HTTPBasicAuthHandler, Request, build_opener + ) except ImportError: + # PY2 + from urllib import urlencode from urllib2 import ( - HTTPBasicAuthHandler, Request, build_opener) # PY2 + HTTPBasicAuthHandler, HTTPError, Request, build_opener + ) + from urlparse import urlparse try: - # pylint: disable=ungrouped-imports - from urllib.parse import urlencode, urlparse # PY3 -except ImportError: - # pylint: disable=ungrouped-imports - from urllib import urlencode # PY2 - from urlparse import urlparse # PY2 - - -try: - from subprocess import PIPE, run # PY3.5 + # PY3.5 + from subprocess import PIPE, run except ImportError: from subprocess import CalledProcessError, PIPE, Popen