Skip to content

Commit

Permalink
drop last bits of python 2 (#659)
Browse files Browse the repository at this point in the history
* drop last bits of python 2
* drop py35 support
  • Loading branch information
ocefpaf authored Feb 26, 2020
1 parent 4d4f068 commit 79f9430
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 31 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: python
python:
- "3.5"
- "3.6"
- "3.7"
- "3.8"
Expand Down
12 changes: 0 additions & 12 deletions owslib/feature/common.py
Original file line number Diff line number Diff line change
@@ -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
"""
Expand Down
8 changes: 4 additions & 4 deletions owslib/feature/wfs100.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from owslib import util

from io import BytesIO
from urllib.parse import urlencode
from owslib.util import (
testXMLValue,
Expand All @@ -27,7 +28,6 @@
from owslib.feature.common import (
WFSCapabilitiesReader,
AbstractContentMetadata,
makeStringIO,
)

import pyproj
Expand Down Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions owslib/feature/wfs110.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Contact email: [email protected]
# =============================================================================

from io import BytesIO
from urllib.parse import urlencode
from owslib.util import (
testXMLValue,
Expand All @@ -33,7 +34,6 @@
from owslib.feature.common import (
WFSCapabilitiesReader,
AbstractContentMetadata,
makeStringIO,
)
from owslib.namespaces import Namespaces
from owslib.util import log, openURL
Expand Down Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions owslib/feature/wfs200.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 0 additions & 4 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def run_tests(self):
maintainer_email = '[email protected]',
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 = [
Expand Down
2 changes: 1 addition & 1 deletion tests/doctests/wfs_MapServerWFSFeature.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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('<wfs:FeatureCollection') > 0
>>> response.read().find(b'<wfs:FeatureCollection') > 0
True

Handle service exception
Expand Down

0 comments on commit 79f9430

Please sign in to comment.