mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Simplify XML query
This commit is contained in:
parent
51a8312f1e
commit
c1653937d1
1 changed files with 5 additions and 8 deletions
|
|
@ -129,10 +129,9 @@ class Discover(object):
|
||||||
data=body, is_subpath=False)
|
data=body, is_subpath=False)
|
||||||
root = _parse_xml(response.content)
|
root = _parse_xml(response.content)
|
||||||
|
|
||||||
for element in root.iter('{*}current-user-principal'):
|
for principal in root.iter('{*}current-user-principal/{*}href'):
|
||||||
for principal in element.iter(): # should be only one
|
# should be only one
|
||||||
if principal.tag.endswith('href'):
|
yield principal.text
|
||||||
yield principal.text
|
|
||||||
|
|
||||||
def find_dav(self):
|
def find_dav(self):
|
||||||
return list(self._find_dav()) or ['']
|
return list(self._find_dav()) or ['']
|
||||||
|
|
@ -172,10 +171,8 @@ class Discover(object):
|
||||||
is_subpath=False)
|
is_subpath=False)
|
||||||
|
|
||||||
root = etree.fromstring(response.content)
|
root = etree.fromstring(response.content)
|
||||||
for element in root.iter(self._homeset_tag):
|
for homeset in root.iter(self._homeset_tag + '/{*}href'):
|
||||||
for homeset in element.iter():
|
yield homeset.text
|
||||||
if homeset.tag.endswith('href'):
|
|
||||||
yield homeset.text
|
|
||||||
|
|
||||||
def find_collections(self):
|
def find_collections(self):
|
||||||
for home in itertools.chain(self.find_homes(), ['']):
|
for home in itertools.chain(self.find_homes(), ['']):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue