Skip to content

Commit 71e64bd

Browse files
authored
use flag instead of for-else in csw:retrecords (#919)
* for-else works on inner loop only * rename found_xml param fix flake8 error
1 parent 2f00ab8 commit 71e64bd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

owslib/catalogue/csw2.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ def getdomain(self, dname, dtype='parameter'):
187187
# get the list of values associated with the Domain
188188
self.results['values'] = []
189189

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

195195
def getrecords(self, qtype=None, keywords=[], typenames='csw:Record', propertyname='csw:AnyText', bbox=None,
196196
esn='summary', sortby=None, outputschema=namespaces['csw'], format=outputformat, startposition=0,
@@ -664,15 +664,16 @@ def _invoke(self):
664664
post_verbs = [x for x in op.methods if x.get('type').lower() == 'post']
665665
if len(post_verbs) > 1:
666666
# Filter by constraints. We must match a PostEncoding of "XML"
667+
found_xml = False
667668
for pv in post_verbs:
668669
for const in pv.get('constraints'):
669670
if const.name.lower() == 'postencoding':
670671
values = [v.lower() for v in const.values]
671672
if 'xml' in values:
672673
request_url = pv.get('url')
674+
found_xml = True
673675
break
674-
else:
675-
# Well, just use the first one.
676+
if not found_xml: # Well, just use the first one.
676677
request_url = post_verbs[0].get('url')
677678
elif len(post_verbs) == 1:
678679
request_url = post_verbs[0].get('url')

0 commit comments

Comments
 (0)