1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-09-15 20:36:55 +00:00

Rework XML helpers functions

- Merge make_tag, tag_from_clark and tag_from_human into make_clark and make_human
- Don't use RegEx for parsing
This commit is contained in:
Unrud 2020-01-19 18:53:05 +01:00
parent 262d76cc87
commit d3776e55fb
10 changed files with 200 additions and 198 deletions

View file

@ -35,17 +35,17 @@ def xml_add_propstat_to(element, tag, status_number):
``status_number``.
"""
propstat = ET.Element(xmlutils.make_tag("D", "propstat"))
propstat = ET.Element(xmlutils.make_clark("D:propstat"))
element.append(propstat)
prop = ET.Element(xmlutils.make_tag("D", "prop"))
prop = ET.Element(xmlutils.make_clark("D:prop"))
propstat.append(prop)
clark_tag = tag if "{" in tag else xmlutils.make_tag(*tag.split(":", 1))
clark_tag = xmlutils.make_clark(tag)
prop_tag = ET.Element(clark_tag)
prop.append(prop_tag)
status = ET.Element(xmlutils.make_tag("D", "status"))
status = ET.Element(xmlutils.make_clark("D:status"))
status.text = xmlutils.make_response(status_number)
propstat.append(status)
@ -60,11 +60,11 @@ def xml_proppatch(base_prefix, path, xml_request, collection):
props_to_remove = xmlutils.props_from_request(xml_request,
actions=("remove",))
multistatus = ET.Element(xmlutils.make_tag("D", "multistatus"))
response = ET.Element(xmlutils.make_tag("D", "response"))
multistatus = ET.Element(xmlutils.make_clark("D:multistatus"))
response = ET.Element(xmlutils.make_clark("D:response"))
multistatus.append(response)
href = ET.Element(xmlutils.make_tag("D", "href"))
href = ET.Element(xmlutils.make_clark("D:href"))
href.text = xmlutils.make_href(base_prefix, path)
response.append(href)