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

Python 3 compatiability fixes; measurement result example changes #230

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
26 changes: 13 additions & 13 deletions wof/WaterML_1_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def quote_xml(inStr):
"Escape markup chars, but do not modify CDATA sections."
if not inStr:
return ''
s1 = (isinstance(inStr, basestring) and inStr or
s1 = (isinstance(inStr, str) and inStr or
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I don't have any stake in this so when I say that in almost 2019 and going all in for Python 3 is 👍 take it with a grain of salt.

If Python 2 and 3 support is needed you may look into tools like six and lines like this one, for example, would be six.string_types instead.

'%s' % inStr)
s2 = ''
pos = 0
Expand All @@ -413,7 +413,7 @@ def quote_xml_aux(inStr):


def quote_attrib(inStr):
s1 = (isinstance(inStr, basestring) and inStr or
s1 = (isinstance(inStr, str) and inStr or
'%s' % inStr)
s1 = s1.replace(u'&', u'&')
s1 = s1.replace(u'<', u'&lt;')
Expand Down Expand Up @@ -826,7 +826,7 @@ class VariableInfoType(GeneratedsSuper):
superclass = None
def __init__(self, metadataTime=None, oid=None, variableCode=None, variableName=None, variableDescription=None, valueType=None, dataType=None, generalCategory=None, sampleMedium=None, unit=None, options=None, note=None, related=None, extension=None, noDataValue=None, timeScale=None, speciation=None, categories=None, variableProperty=None):
self.original_tagname_ = None
if isinstance(metadataTime, basestring):
if isinstance(metadataTime, str):
initvalue_ = datetime.datetime.strptime(metadataTime, '%Y-%m-%dT%H:%M:%S')
else:
initvalue_ = metadataTime
Expand Down Expand Up @@ -1321,7 +1321,7 @@ class QueryInfoType(GeneratedsSuper):
superclass = None
def __init__(self, creationTime=None, queryURL=None, criteria=None, note=None, extension=None):
self.original_tagname_ = None
if isinstance(creationTime, basestring):
if isinstance(creationTime, str):
initvalue_ = datetime.datetime.strptime(creationTime, '%Y-%m-%dT%H:%M:%S')
else:
initvalue_ = creationTime
Expand Down Expand Up @@ -1701,22 +1701,22 @@ class TimePeriodType(GeneratedsSuper):
superclass = None
def __init__(self, beginDateTime=None, endDateTime=None, beginDateTimeUTC=None, endDateTimeUTC=None, extensiontype_=None):
self.original_tagname_ = None
if isinstance(beginDateTime, basestring):
if isinstance(beginDateTime, str):
initvalue_ = datetime.datetime.strptime(beginDateTime, '%Y-%m-%dT%H:%M:%S')
else:
initvalue_ = beginDateTime
self.beginDateTime = initvalue_
if isinstance(endDateTime, basestring):
if isinstance(endDateTime, str):
initvalue_ = datetime.datetime.strptime(endDateTime, '%Y-%m-%dT%H:%M:%S')
else:
initvalue_ = endDateTime
self.endDateTime = initvalue_
if isinstance(beginDateTimeUTC, basestring):
if isinstance(beginDateTimeUTC, str):
initvalue_ = datetime.datetime.strptime(beginDateTimeUTC, '%Y-%m-%dT%H:%M:%S')
else:
initvalue_ = beginDateTimeUTC
self.beginDateTimeUTC = initvalue_
if isinstance(endDateTimeUTC, basestring):
if isinstance(endDateTimeUTC, str):
initvalue_ = datetime.datetime.strptime(endDateTimeUTC, '%Y-%m-%dT%H:%M:%S')
else:
initvalue_ = endDateTimeUTC
Expand Down Expand Up @@ -1883,7 +1883,7 @@ class TimeSingleType(TimePeriodType):
def __init__(self, beginDateTime=None, endDateTime=None, beginDateTimeUTC=None, endDateTimeUTC=None, timeSingle=None):
self.original_tagname_ = None
super(TimeSingleType, self).__init__(beginDateTime, endDateTime, beginDateTimeUTC, endDateTimeUTC, )
if isinstance(timeSingle, basestring):
if isinstance(timeSingle, str):
initvalue_ = datetime.datetime.strptime(timeSingle, '%Y-%m-%dT%H:%M:%S')
else:
initvalue_ = timeSingle
Expand Down Expand Up @@ -3038,7 +3038,7 @@ def __init__(self, codedVocabularyTerm=None, sampleID=None, methodCode=None, qua
self.methodCode = _cast(None, methodCode)
self.qualityControlLevelCode = _cast(None, qualityControlLevelCode)
self.methodID = _cast(int, methodID)
if isinstance(metadataTime, basestring):
if isinstance(metadataTime, str):
initvalue_ = datetime.datetime.strptime(metadataTime, '%Y-%m-%dT%H:%M:%S')
else:
initvalue_ = metadataTime
Expand All @@ -3049,13 +3049,13 @@ def __init__(self, codedVocabularyTerm=None, sampleID=None, methodCode=None, qua
self.censorCode = _cast(None, censorCode)
self.accuracyStdDev = _cast(float, accuracyStdDev)
self.offsetTypeID = _cast(int, offsetTypeID)
if isinstance(dateTime, basestring):
if isinstance(dateTime, str):
initvalue_ = datetime.datetime.strptime(dateTime, '%Y-%m-%dT%H:%M:%S')
else:
initvalue_ = dateTime
self.dateTime = initvalue_
self.offsetTypeCode = _cast(None, offsetTypeCode)
if isinstance(dateTimeUTC, basestring):
if isinstance(dateTimeUTC, str):
initvalue_ = datetime.datetime.strptime(dateTimeUTC, '%Y-%m-%dT%H:%M:%S')
else:
initvalue_ = dateTimeUTC
Expand Down Expand Up @@ -7221,7 +7221,7 @@ class SiteInfoType(SourceInfoType):
def __init__(self, metadataTime=None, oid=None, siteName=None, siteCode=None, timeZoneInfo=None, geoLocation=None, elevation_m=None, verticalDatum=None, note=None, extension=None, altname=None, siteType=None, siteProperty=None):
self.original_tagname_ = None
super(SiteInfoType, self).__init__()
if isinstance(metadataTime, basestring):
if isinstance(metadataTime, str):
initvalue_ = datetime.datetime.strptime(metadataTime, '%Y-%m-%dT%H:%M:%S')
else:
initvalue_ = metadataTime
Expand Down
2 changes: 1 addition & 1 deletion wof/apps/waterml2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import (absolute_import, division, print_function)

import StringIO
from io import StringIO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may needs to treat things as BytesIO instead.

import logging
import datetime
import os
Expand Down
18 changes: 12 additions & 6 deletions wof/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@

from dateutil.parser import parse

from lxml import etree
from lxml.etree import XMLParser
from lxml.etree import XMLSyntaxError

import pytz

from spyne.application import Application
from spyne.const.http import HTTP_405
from spyne.error import RequestNotAllowed
Expand All @@ -27,6 +21,18 @@
from spyne.server.http import HttpTransportContext
from spyne.server.wsgi import WsgiApplication

import sys
print('sys.path!!!!')
print(sys.path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this is left over debugging statements.

PS: using env will give you path isolation and reduce headaches.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, thanks, removed now.


import pytz
from lxml import etree
from lxml.etree import XMLParser
from lxml.etree import XMLSyntaxError




from wof.WofWsdls import WofWSDL_1_0, WofWSDL_1_1
from wof.apps.spyned_1_0 import TWOFService as wml10
from wof.apps.spyned_1_1 import TWOFService as wml11
Expand Down
Loading