Skip to content

Commit

Permalink
use flag instead of for-else in csw:retrecords (#919)
Browse files Browse the repository at this point in the history
* for-else works on inner loop only

* rename found_xml param
fix flake8 error
  • Loading branch information
pvgenuchten committed Apr 4, 2024
1 parent 2f00ab8 commit 71e64bd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions owslib/catalogue/csw2.py
Expand Up @@ -187,10 +187,10 @@ def getdomain(self, dname, dtype='parameter'):
# get the list of values associated with the Domain
self.results['values'] = []

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

def getrecords(self, qtype=None, keywords=[], typenames='csw:Record', propertyname='csw:AnyText', bbox=None,
esn='summary', sortby=None, outputschema=namespaces['csw'], format=outputformat, startposition=0,
Expand Down Expand Up @@ -664,15 +664,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 71e64bd

Please sign in to comment.