Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop last bits of python 2 #659

Merged
merged 2 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: tomkralidis@gmail.com
# =============================================================================

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 = '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 = [
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