From c6a023d00e1fd57ddfee475737df72706ba47404 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Wed, 19 Feb 2020 16:51:24 -0300 Subject: [PATCH 1/2] drop last bits of python 2 --- owslib/feature/common.py | 12 ------------ owslib/feature/wfs100.py | 8 ++++---- owslib/feature/wfs110.py | 8 ++++---- owslib/feature/wfs200.py | 8 ++++---- requirements-dev.txt | 4 ---- tests/doctests/wfs_MapServerWFSFeature.txt | 2 +- 6 files changed, 13 insertions(+), 29 deletions(-) diff --git a/owslib/feature/common.py b/owslib/feature/common.py index e787bde71..e097c793a 100644 --- a/owslib/feature/common.py +++ b/owslib/feature/common.py @@ -1,21 +1,9 @@ -from io import StringIO from owslib.etree import etree from owslib.util import Authentication, openURL from urllib.parse import urlencode, parse_qsl -def makeStringIO(strval): - """ - Helper method to make sure the StringIO being returned will work. - - Differences between Python 2.7/3.x mean we have a lot of cases to handle. - - TODO: skipped Python 2.x support. Is this still necessary? - """ - return StringIO(strval.decode()) - - class WFSCapabilitiesReader(object): """Read and parse capabilities document into a lxml.etree infoset """ diff --git a/owslib/feature/wfs100.py b/owslib/feature/wfs100.py index 80d6de24d..722cdb3b7 100644 --- a/owslib/feature/wfs100.py +++ b/owslib/feature/wfs100.py @@ -8,6 +8,7 @@ from owslib import util +from io import BytesIO from urllib.parse import urlencode from owslib.util import ( testXMLValue, @@ -27,7 +28,6 @@ from owslib.feature.common import ( WFSCapabilitiesReader, AbstractContentMetadata, - makeStringIO, ) import pyproj @@ -308,16 +308,16 @@ def getfeature( tree = etree.fromstring(data) except BaseException: # Not XML - return makeStringIO(data) + return BytesIO(data) else: if tree.tag == "{%s}ServiceExceptionReport" % OGC_NAMESPACE: se = tree.find(nspath("ServiceException", OGC_NAMESPACE)) raise ServiceException(str(se.text).strip()) else: - return makeStringIO(data) + return BytesIO(data) else: if have_read: - return makeStringIO(data) + return BytesIO(data) return u def getOperationByName(self, name): diff --git a/owslib/feature/wfs110.py b/owslib/feature/wfs110.py index 7e483ff8b..34db9ed4e 100644 --- a/owslib/feature/wfs110.py +++ b/owslib/feature/wfs110.py @@ -7,6 +7,7 @@ # Contact email: tomkralidis@gmail.com # ============================================================================= +from io import BytesIO from urllib.parse import urlencode from owslib.util import ( testXMLValue, @@ -33,7 +34,6 @@ from owslib.feature.common import ( WFSCapabilitiesReader, AbstractContentMetadata, - makeStringIO, ) from owslib.namespaces import Namespaces from owslib.util import log, openURL @@ -346,16 +346,16 @@ def getfeature( tree = etree.fromstring(data) except BaseException: # Not XML - return makeStringIO(data) + return BytesIO(data) else: if tree.tag == "{%s}ServiceExceptionReport" % namespaces["ogc"]: se = tree.find(nspath_eval("ServiceException", namespaces["ogc"])) raise ServiceException(str(se.text).strip()) else: - return makeStringIO(data) + return BytesIO(data) else: if have_read: - return makeStringIO(data) + return BytesIO(data) return u def getOperationByName(self, name): diff --git a/owslib/feature/wfs200.py b/owslib/feature/wfs200.py index 53214defc..4951aab02 100644 --- a/owslib/feature/wfs200.py +++ b/owslib/feature/wfs200.py @@ -18,11 +18,11 @@ from owslib.feature.common import ( WFSCapabilitiesReader, AbstractContentMetadata, - makeStringIO, ) from owslib.namespaces import Namespaces # other imports +from io import BytesIO from urllib.parse import urlencode import logging @@ -313,16 +313,16 @@ def getfeature( tree = etree.fromstring(data) except BaseException: # Not XML - return makeStringIO(data) + return BytesIO(data) else: if tree.tag == "{%s}ServiceExceptionReport" % OGC_NAMESPACE: se = tree.find(nspath("ServiceException", OGC_NAMESPACE)) raise ServiceException(str(se.text).strip()) else: - return makeStringIO(data) + return BytesIO(data) else: if have_read: - return makeStringIO(data) + return BytesIO(data) return u def getpropertyvalue( diff --git a/requirements-dev.txt b/requirements-dev.txt index 2aa2a0a6b..11e2eef86 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,7 +4,3 @@ pytest>=3.6 pytest-cov Pillow tox -# install libraries to stop SSL related InsecurePlatformWarning -pyopenssl ; python_version < '2.7.9' -ndg-httpsclient ; python_version < '2.7.9' -pyasn1 ; python_version < '2.7.9' diff --git a/tests/doctests/wfs_MapServerWFSFeature.txt b/tests/doctests/wfs_MapServerWFSFeature.txt index cf62a3be4..50cf899ad 100644 --- a/tests/doctests/wfs_MapServerWFSFeature.txt +++ b/tests/doctests/wfs_MapServerWFSFeature.txt @@ -7,7 +7,7 @@ Test the getfeature method >>> wfs = WebFeatureService('http://nsidc.org/cgi-bin/atlas_south?', version='1.0.0') >>> response = wfs.getfeature(typename=['glaciers'], maxfeatures=5) - >>> response.read().find(' 0 + >>> response.read().find(b' 0 True Handle service exception From 3a44b1d7dcb1817f7682fcbffa895a85f847d1c0 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Thu, 20 Feb 2020 09:55:25 -0300 Subject: [PATCH 2/2] drop py35 support --- .travis.yml | 1 - setup.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 702140e92..341ad2f6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: python python: - - "3.5" - "3.6" - "3.7" - "3.8" diff --git a/setup.py b/setup.py index 7061a353a..3543bdbc3 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ def run_tests(self): maintainer_email = 'tomkralidis@gmail.com', url = 'https://geopython.github.io/OWSLib', install_requires = reqs, - python_requires = '>=3.5', + python_requires = '>=3.6', cmdclass = {'test': PyTest}, packages = find_packages(exclude=["docs", "etc", "examples", "tests"]), classifiers = [