Skip to content

Commit 47ee342

Browse files
Substitute the d: prefix for the DAV: namespace with no prefix(default namespace)
1 parent acac9db commit 47ee342

File tree

2 files changed

+75
-75
lines changed

2 files changed

+75
-75
lines changed

tests/storage/dav/test_main.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@
77

88
def test_xml_utilities():
99
x = _parse_xml(b'''<?xml version="1.0" encoding="UTF-8" ?>
10-
<D:multistatus xmlns:D="DAV:">
11-
<D:response>
12-
<D:propstat>
13-
<D:status>HTTP/1.1 404 Not Found</D:status>
14-
<D:prop>
15-
<D:getcontenttype/>
16-
</D:prop>
17-
</D:propstat>
18-
<D:propstat>
19-
<D:prop>
20-
<D:resourcetype>
21-
<D:collection/>
22-
</D:resourcetype>
23-
</D:prop>
24-
</D:propstat>
25-
</D:response>
26-
</D:multistatus>
10+
<multistatus xmlns="DAV:">
11+
<response>
12+
<propstat>
13+
<status>HTTP/1.1 404 Not Found</D:status>
14+
<prop>
15+
<getcontenttype/>
16+
</prop>
17+
</propstat>
18+
<propstat>
19+
<prop>
20+
<resourcetype>
21+
<collection/>
22+
</resourcetype>
23+
</prop>
24+
</propstat>
25+
</response>
26+
</multistatus>
2727
''')
2828

2929
response = x.find('{DAV:}response')

vdirsyncer/storage/dav.py

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ class Discover:
150150
_homeset_tag = None
151151
_well_known_uri = None
152152
_collection_xml = b"""
153-
<d:propfind xmlns:d="DAV:">
154-
<d:prop>
155-
<d:resourcetype />
156-
</d:prop>
157-
</d:propfind>
153+
<propfind xmlns="DAV:">
154+
<prop>
155+
<resourcetype />
156+
</prop>
157+
</propfind>
158158
"""
159159

160160
def __init__(self, session, kwargs):
@@ -180,11 +180,11 @@ def _find_principal_impl(self, url):
180180
headers = self.session.get_default_headers()
181181
headers['Depth'] = '0'
182182
body = b"""
183-
<d:propfind xmlns:d="DAV:">
184-
<d:prop>
185-
<d:current-user-principal />
186-
</d:prop>
187-
</d:propfind>
183+
<propfind xmlns="DAV:">
184+
<prop>
185+
<current-user-principal />
186+
</prop>
187+
</propfind>
188188
"""
189189

190190
response = self.session.request('PROPFIND', url, headers=headers,
@@ -300,16 +300,16 @@ def create(self, collection):
300300

301301
def _create_collection_impl(self, url):
302302
data = '''<?xml version="1.0" encoding="utf-8" ?>
303-
<D:mkcol xmlns:D="DAV:">
304-
<D:set>
305-
<D:prop>
306-
<D:resourcetype>
307-
<D:collection/>
303+
<mkcol xmlns="DAV:">
304+
<set>
305+
<prop>
306+
<resourcetype>
307+
<collection/>
308308
{}
309-
</D:resourcetype>
310-
</D:prop>
311-
</D:set>
312-
</D:mkcol>
309+
</resourcetype>
310+
</prop>
311+
</set>
312+
</mkcol>
313313
'''.format(
314314
etree.tostring(etree.Element(self._resourcetype),
315315
encoding='unicode')
@@ -328,11 +328,11 @@ class CalDiscover(Discover):
328328
_namespace = 'urn:ietf:params:xml:ns:caldav'
329329
_resourcetype = '{%s}calendar' % _namespace
330330
_homeset_xml = b"""
331-
<d:propfind xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
332-
<d:prop>
331+
<propfind xmlns="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
332+
<prop>
333333
<c:calendar-home-set />
334-
</d:prop>
335-
</d:propfind>
334+
</prop>
335+
</propfind>
336336
"""
337337
_homeset_tag = '{%s}calendar-home-set' % _namespace
338338
_well_known_uri = '/.well-known/caldav'
@@ -342,11 +342,11 @@ class CardDiscover(Discover):
342342
_namespace = 'urn:ietf:params:xml:ns:carddav'
343343
_resourcetype = '{%s}addressbook' % _namespace
344344
_homeset_xml = b"""
345-
<d:propfind xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
346-
<d:prop>
345+
<propfind xmlns="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
346+
<prop>
347347
<c:addressbook-home-set />
348-
</d:prop>
349-
</d:propfind>
348+
</prop>
349+
</propfind>
350350
"""
351351
_homeset_tag = '{%s}addressbook-home-set' % _namespace
352352
_well_known_uri = '/.well-known/carddav'
@@ -463,7 +463,7 @@ def get_multi(self, hrefs):
463463
for href in hrefs:
464464
if href != self._normalize_href(href):
465465
raise exceptions.NotFoundError(href)
466-
href_xml.append(f'<D:href>{href}</D:href>')
466+
href_xml.append(f'<href>{href}</href>')
467467
if not href_xml:
468468
return ()
469469

@@ -620,13 +620,13 @@ def list(self):
620620
headers['Depth'] = '1'
621621

622622
data = b'''<?xml version="1.0" encoding="utf-8" ?>
623-
<D:propfind xmlns:D="DAV:">
624-
<D:prop>
625-
<D:resourcetype/>
626-
<D:getcontenttype/>
627-
<D:getetag/>
628-
</D:prop>
629-
</D:propfind>
623+
<propfind xmlns="DAV:">
624+
<prop>
625+
<resourcetype/>
626+
<getcontenttype/>
627+
<getetag/>
628+
</prop>
629+
</propfind>
630630
'''
631631

632632
# We use a PROPFIND request instead of addressbook-query due to issues
@@ -647,11 +647,11 @@ def get_meta(self, key):
647647

648648
xpath = f'{{{namespace}}}{tagname}'
649649
data = '''<?xml version="1.0" encoding="utf-8" ?>
650-
<D:propfind xmlns:D="DAV:">
651-
<D:prop>
650+
<propfind xmlns="DAV:">
651+
<prop>
652652
{}
653-
</D:prop>
654-
</D:propfind>
653+
</prop>
654+
</propfind>
655655
'''.format(
656656
etree.tostring(etree.Element(xpath), encoding='unicode')
657657
).encode('utf-8')
@@ -683,13 +683,13 @@ def set_meta(self, key, value):
683683
element.text = normalize_meta_value(value)
684684

685685
data = '''<?xml version="1.0" encoding="utf-8" ?>
686-
<D:propertyupdate xmlns:D="DAV:">
687-
<D:set>
688-
<D:prop>
686+
<propertyupdate xmlns="DAV:">
687+
<set>
688+
<prop>
689689
{}
690-
</D:prop>
691-
</D:set>
692-
</D:propertyupdate>
690+
</prop>
691+
</set>
692+
</propertyupdate>
693693
'''.format(etree.tostring(element, encoding='unicode')).encode('utf-8')
694694

695695
self.session.request(
@@ -714,12 +714,12 @@ class CalDAVStorage(DAVStorage):
714714
end_date = None
715715

716716
get_multi_template = '''<?xml version="1.0" encoding="utf-8" ?>
717-
<C:calendar-multiget xmlns:D="DAV:"
717+
<C:calendar-multiget xmlns="DAV:"
718718
xmlns:C="urn:ietf:params:xml:ns:caldav">
719-
<D:prop>
720-
<D:getetag/>
719+
<prop>
720+
<getetag/>
721721
<C:calendar-data/>
722-
</D:prop>
722+
</prop>
723723
{hrefs}
724724
</C:calendar-multiget>'''
725725

@@ -798,12 +798,12 @@ def list(self):
798798
yield from DAVStorage.list(self)
799799

800800
data = '''<?xml version="1.0" encoding="utf-8" ?>
801-
<C:calendar-query xmlns:D="DAV:"
801+
<C:calendar-query xmlns="DAV:"
802802
xmlns:C="urn:ietf:params:xml:ns:caldav">
803-
<D:prop>
804-
<D:getcontenttype/>
805-
<D:getetag/>
806-
</D:prop>
803+
<prop>
804+
<getcontenttype/>
805+
<getetag/>
806+
</prop>
807807
<C:filter>
808808
{caldavfilter}
809809
</C:filter>
@@ -835,12 +835,12 @@ class CardDAVStorage(DAVStorage):
835835
discovery_class = CardDiscover
836836

837837
get_multi_template = '''<?xml version="1.0" encoding="utf-8" ?>
838-
<C:addressbook-multiget xmlns:D="DAV:"
838+
<C:addressbook-multiget xmlns="DAV:"
839839
xmlns:C="urn:ietf:params:xml:ns:carddav">
840-
<D:prop>
841-
<D:getetag/>
840+
<prop>
841+
<getetag/>
842842
<C:address-data/>
843-
</D:prop>
843+
</prop>
844844
{hrefs}
845845
</C:addressbook-multiget>'''
846846

0 commit comments

Comments
 (0)