Fix bug with combination of yield and return

Thanks van Rossum!
This commit is contained in:
Markus Unterwaditzer 2016-09-30 09:01:25 +02:00
parent 841318208d
commit 3aca7e247a

View file

@ -186,20 +186,19 @@ class Discover(object):
raise InvalidXMLResponse('Couldn\'t find home-set.') raise InvalidXMLResponse('Couldn\'t find home-set.')
return urlparse.urljoin(response.url, rv.text) return urlparse.urljoin(response.url, rv.text)
def find_collections(self, url=None): def find_collections(self):
if url is None: rv = None
rv = None try:
try: rv = list(self._find_collections_impl(''))
rv = list(self.find_collections('')) except (HTTPError, exceptions.Error):
except (HTTPError, exceptions.Error): pass
pass
if rv: if rv:
yield from rv return rv
return dav_logger.debug('Given URL is not a homeset URL')
dav_logger.debug('Given URL is not a homeset URL') return self._find_collections_impl(self.find_home())
return self.find_collections(self.find_home())
def _find_collections_impl(self, url):
headers = self.session.get_default_headers() headers = self.session.get_default_headers()
headers['Depth'] = '1' headers['Depth'] = '1'
r = self.session.request('PROPFIND', url, headers=headers, r = self.session.request('PROPFIND', url, headers=headers,