Remove useless calls to _tag

This commit is contained in:
Guillaume Ayoub 2011-05-11 08:39:32 +02:00
parent ac83dadc9c
commit 3b17ed2969

View File

@ -89,15 +89,13 @@ def delete(path, calendar):
calendar.remove(name_from_path(path, calendar)) calendar.remove(name_from_path(path, calendar))
# Writing answer # Writing answer
multistatus = ET.Element(_tag("D", "multistatus")) multistatus = ET.Element("{D}multistatus")
response = ET.Element(_tag("D", "response")) response = ET.Element("{D}response")
multistatus.append(response) multistatus.append(response)
href = ET.Element(_tag("D", "href"))
href.text = path href.text = path
response.append(href) response.append(href)
status = ET.Element(_tag("D", "status")) status = ET.Element("{D}status")
status.text = _response(200) status.text = _response(200)
response.append(status) response.append(status)
@ -120,7 +118,7 @@ def propfind(path, xml_request, calendar, depth):
props = [prop.tag for prop in prop_element] props = [prop.tag for prop in prop_element]
# Writing answer # Writing answer
multistatus = ET.Element(_tag("D", "multistatus")) multistatus = ET.Element("{D}multistatus")
if calendar: if calendar:
if depth == "0": if depth == "0":
@ -135,25 +133,25 @@ def propfind(path, xml_request, calendar, depth):
for item in items: for item in items:
is_calendar = isinstance(item, ical.Calendar) is_calendar = isinstance(item, ical.Calendar)
response = ET.Element(_tag("D", "response")) response = ET.Element("{D}response")
multistatus.append(response) multistatus.append(response)
href = ET.Element(_tag("D", "href")) href = ET.Element("{D}href")
href.text = path if is_calendar else path + item.name href.text = path if is_calendar else path + item.name
response.append(href) response.append(href)
propstat = ET.Element(_tag("D", "propstat")) propstat = ET.Element("{D}propstat")
response.append(propstat) response.append(propstat)
prop = ET.Element(_tag("D", "prop")) prop = ET.Element("{D}prop")
propstat.append(prop) propstat.append(prop)
for tag in props: for tag in props:
element = ET.Element(tag) element = ET.Element(tag)
if tag == _tag("D", "resourcetype") and is_calendar: if tag == _tag("D", "resourcetype") and is_calendar:
tag = ET.Element(_tag("C", "calendar")) tag = ET.Element("{C}calendar")
element.append(tag) element.append(tag)
tag = ET.Element(_tag("D", "collection")) tag = ET.Element("{D}collection")
element.append(tag) element.append(tag)
elif tag == _tag("D", "owner"): elif tag == _tag("D", "owner"):
if calendar.owner: if calendar.owner:
@ -168,40 +166,40 @@ def propfind(path, xml_request, calendar, depth):
element.text = calendar.name element.text = calendar.name
elif tag == _tag("D", "principal-URL"): elif tag == _tag("D", "principal-URL"):
# TODO: use a real principal URL, read rfc3744-4.2 for info # TODO: use a real principal URL, read rfc3744-4.2 for info
tag = ET.Element(_tag("D", "href")) tag = ET.Element("{D}href")
tag.text = path tag.text = path
element.append(tag) element.append(tag)
elif tag in ( elif tag in (
_tag("D", "principal-collection-set"), _tag("D", "principal-collection-set"),
_tag("C", "calendar-user-address-set"), _tag("C", "calendar-user-address-set"),
_tag("C", "calendar-home-set")): _tag("C", "calendar-home-set")):
tag = ET.Element(_tag("D", "href")) tag = ET.Element("{D}href")
tag.text = path tag.text = path
element.append(tag) element.append(tag)
elif tag == _tag("C", "supported-calendar-component-set"): elif tag == _tag("C", "supported-calendar-component-set"):
# This is not a Todo # This is not a Todo
# pylint: disable=W0511 # pylint: disable=W0511
for component in ("VTODO", "VEVENT", "VJOURNAL"): for component in ("VTODO", "VEVENT", "VJOURNAL"):
comp = ET.Element(_tag("C", "comp")) comp = ET.Element("{C}comp")
comp.set("name", component) comp.set("name", component)
element.append(comp) element.append(comp)
# pylint: enable=W0511 # pylint: enable=W0511
elif tag == _tag("D", "current-user-privilege-set"): elif tag == _tag("D", "current-user-privilege-set"):
privilege = ET.Element(_tag("D", "privilege")) privilege = ET.Element("{D}privilege")
privilege.append(ET.Element(_tag("D", "all"))) privilege.append(ET.Element("{D}all"))
element.append(privilege) element.append(privilege)
elif tag == _tag("D", "supported-report-set"): elif tag == _tag("D", "supported-report-set"):
for report_name in ( for report_name in (
"principal-property-search", "sync-collection" "principal-property-search", "sync-collection"
"expand-property", "principal-search-property-set"): "expand-property", "principal-search-property-set"):
supported = ET.Element(_tag("D", "supported-report")) supported = ET.Element("{D}supported-report")
report_tag = ET.Element(_tag("D", "report")) report_tag = ET.Element("{D}report")
report_tag.text = report_name report_tag.text = report_name
supported.append(report_tag) supported.append(report_tag)
element.append(supported) element.append(supported)
prop.append(element) prop.append(element)
status = ET.Element(_tag("D", "status")) status = ET.Element("{D}status")
status.text = _response(200) status.text = _response(200)
propstat.append(status) propstat.append(status)
@ -228,26 +226,26 @@ def proppatch(path, xml_request, calendar):
props.extend(prop.tag for prop in prop_element) props.extend(prop.tag for prop in prop_element)
# Writing answer # Writing answer
multistatus = ET.Element(_tag("D", "multistatus")) multistatus = ET.Element("{D}multistatus")
response = ET.Element(_tag("D", "response")) response = ET.Element("{D}response")
multistatus.append(response) multistatus.append(response)
href = ET.Element(_tag("D", "href")) href = ET.Element("{D}href")
href.text = path href.text = path
response.append(href) response.append(href)
propstat = ET.Element(_tag("D", "propstat")) propstat = ET.Element("{D}propstat")
response.append(propstat) response.append(propstat)
prop = ET.Element(_tag("D", "prop")) prop = ET.Element("{D}prop")
propstat.append(prop) propstat.append(prop)
for tag in props: for tag in props:
element = ET.Element(tag) element = ET.Element(tag)
prop.append(element) prop.append(element)
status = ET.Element(_tag("D", "status")) status = ET.Element("{D}status")
status.text = _response(200) status.text = _response(200)
propstat.append(status) propstat.append(status)
@ -292,7 +290,7 @@ def report(path, xml_request, calendar):
hreferences = () hreferences = ()
# Writing answer # Writing answer
multistatus = ET.Element(_tag("D", "multistatus")) multistatus = ET.Element("{D}multistatus")
for hreference in hreferences: for hreference in hreferences:
# Check if the reference is an item or a calendar # Check if the reference is an item or a calendar
@ -307,17 +305,17 @@ def report(path, xml_request, calendar):
items = calendar.components items = calendar.components
for item in items: for item in items:
response = ET.Element(_tag("D", "response")) response = ET.Element("{D}response")
multistatus.append(response) multistatus.append(response)
href = ET.Element(_tag("D", "href")) href = ET.Element("{D}href")
href.text = path + item.name href.text = path + item.name
response.append(href) response.append(href)
propstat = ET.Element(_tag("D", "propstat")) propstat = ET.Element("{D}propstat")
response.append(propstat) response.append(propstat)
prop = ET.Element(_tag("D", "prop")) prop = ET.Element("{D}prop")
propstat.append(prop) propstat.append(prop)
for tag in props: for tag in props:
@ -330,7 +328,7 @@ def report(path, xml_request, calendar):
calendar.headers, calendar.timezones + [item]) calendar.headers, calendar.timezones + [item])
prop.append(element) prop.append(element)
status = ET.Element(_tag("D", "status")) status = ET.Element("{D}status")
status.text = _response(200) status.text = _response(200)
propstat.append(status) propstat.append(status)