Closed naavis closed 10 years ago
@naavis thanks. Can you provide a GetCapabilities
response (feel free to send to me offline)? The error is due to a missing element.
The element is missing because the tag is a comment tag. I think comment tags should be completely ignored. I removed all comments from the response and it is parsed correctly. I will send you the response offline.
@naavis thanks. Confirmed. The question is why is this getting picked up by the XML parser to begin with.
Having said this, a safe enough workaround would be:
diff --git a/owslib/ows.py b/owslib/ows.py
index cb5ade5..b1bfd80 100644
--- a/owslib/ows.py
+++ b/owslib/ows.py
@@ -162,6 +162,8 @@ class Constraint(object):
class OperationsMetadata(object):
"""Initialize an OWS OperationMetadata construct"""
def __init__(self, elem, namespace=DEFAULT_OWS_NAMESPACE):
+ if 'name' not in elem.attrib: # this is not a valid element
+ return
self.name = elem.attrib['name']
self.formatOptions = ['text/xml']
parameters = []
does this work for you? If yes, PR is welcome if possible.
@tomkralidis Thanks, the fix seems to work. I will do a pull request.
When creating a WebFeatureService 2.0.0 object with the Finnish Meteorological Institute's WFS API the library crashes with the following stack trace:
By stepping through the code I noticed the crash happened when it hit the following comment tag in the
<ows:OperationsMetadata>
part of the GetCapabilities response:Maybe there is a check for comment tags missing somewhere? Since the API is not open for all, I unfortunately cannot paste the whole response here.