Skip to content

Commit

Permalink
same fixes as #919 #918, but to csw3 (#920)
Browse files Browse the repository at this point in the history
  • Loading branch information
pvgenuchten authored Apr 4, 2024
1 parent b26a8b2 commit 79909b4
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions owslib/catalogue/csw3.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,23 +145,25 @@ def getdomain(self, dname, dtype='parameter'):
etree.SubElement(node0, util.nspath_eval('csw30:%s' % dtypename, namespaces)).text = dname

self.request = node0
try: # getdomain operation is optional on CSW3, return empty if failing
self._invoke()

self._invoke()

if self.exceptionreport is None:
self.results = {}
if self.exceptionreport is None:
self.results = {}

val = self._exml.find(util.nspath_eval('csw30:DomainValues', namespaces)).attrib.get('type')
self.results['type'] = util.testXMLValue(val, True)
val = self._exml.find(util.nspath_eval('csw30:DomainValues', namespaces)).attrib.get('type')
self.results['type'] = util.testXMLValue(val, True)

val = self._exml.find(util.nspath_eval('csw30:DomainValues/csw30:%s' % dtypename, namespaces))
self.results[dtype] = util.testXMLValue(val)
val = self._exml.find(util.nspath_eval('csw30:DomainValues/csw30:%s' % dtypename, namespaces))
self.results[dtype] = util.testXMLValue(val)

# get the list of values associated with the Domain
self.results['values'] = []
# get the list of values associated with the Domain
self.results['values'] = []

for f in self._exml.findall(util.nspath_eval('csw30:DomainValues/csw30:ListOfValues/csw30:Value', namespaces)): # noqa
self.results['values'].append(util.testXMLValue(f))
for f in self._exml.findall(util.nspath_eval('csw30:DomainValues/csw30:ListOfValues/csw30:Value', namespaces)): # noqa
self.results['values'].append(util.testXMLValue(f))
except Exception:
self.results = {'values': []}

def getrecordbyid(self, id=[], esn='full', outputschema=namespaces['csw30'], format=outputformat):
"""
Expand Down Expand Up @@ -557,15 +559,16 @@ def _invoke(self):
post_verbs = [x for x in op.methods if x.get('type').lower() == 'post']
if len(post_verbs) > 1:
# Filter by constraints. We must match a PostEncoding of "XML"
found_xml = False
for pv in post_verbs:
for const in pv.get('constraints'):
if const.name.lower() == 'postencoding':
values = [v.lower() for v in const.values]
if 'xml' in values:
request_url = pv.get('url')
found_xml = True
break
else:
# Well, just use the first one.
if not found_xml: # Well, just use the first one.
request_url = post_verbs[0].get('url')
elif len(post_verbs) == 1:
request_url = post_verbs[0].get('url')
Expand Down

0 comments on commit 79909b4

Please sign in to comment.