From c9ddbb319507534c23ba16b10ea1409ca71d6e0a Mon Sep 17 00:00:00 2001 From: Kurt Schwehr Date: Tue, 17 Dec 2019 14:29:34 -0800 Subject: [PATCH] Drop support for python2. With https://www.python.org/doc/sunset-python-2/, the imports can be simpler. The code also doesn't need the __future__ any more now that the future is here. --- ecmwfapi/api.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/ecmwfapi/api.py b/ecmwfapi/api.py index fef0b71..ebb068b 100755 --- a/ecmwfapi/api.py +++ b/ecmwfapi/api.py @@ -7,28 +7,17 @@ # granted to it by virtue of its status as an intergovernmental organisation nor # does it submit to any jurisdiction. -# make the python3-like print behave in python 2 -from __future__ import print_function - import os import sys import time import traceback from contextlib import closing -# python 2 and 3 compatible urllib and httplib imports -try: - from urllib.parse import urlparse - from urllib.parse import urljoin - from urllib.error import HTTPError, URLError - from urllib.request import HTTPRedirectHandler, Request, build_opener, urlopen, addinfourl - from http.client import BadStatusLine -except ImportError: - from urlparse import urlparse - from urlparse import urljoin - from urllib2 import HTTPError, URLError - from urllib2 import HTTPRedirectHandler, Request, build_opener, urlopen, addinfourl - from httplib import BadStatusLine +from http.client import BadStatusLine +from urllib.error import HTTPError, URLError +from urllib.parse import urljoin +from urllib.parse import urlparse +from urllib.request import HTTPRedirectHandler, Request, build_opener, urlopen, addinfourl try: import json