Remove unnecessary conditions

This commit is contained in:
Unrud 2017-03-10 22:16:46 +01:00
parent a7f12b5fac
commit 2f67da5750

View File

@ -691,19 +691,15 @@ def _propfind_response(base_prefix, path, item, props, user, write=False,
element.append(supported) element.append(supported)
elif is_collection: elif is_collection:
if tag == _tag("D", "getcontenttype"): if tag == _tag("D", "getcontenttype"):
item_tag = item.get_meta("tag") if is_leaf:
if item_tag: element.text = MIMETYPES[item.get_meta("tag")]
element.text = MIMETYPES[item_tag]
else: else:
is404 = True is404 = True
elif tag == _tag("D", "resourcetype"): elif tag == _tag("D", "resourcetype"):
if item.is_principal: if item.is_principal:
tag = ET.Element(_tag("D", "principal")) tag = ET.Element(_tag("D", "principal"))
element.append(tag) element.append(tag)
item_tag = item.get_meta("tag") if is_leaf:
if is_leaf or item_tag:
# 2nd case happens when the collection is not stored yet,
# but the resource type is guessed
if item.get_meta("tag") == "VADDRESSBOOK": if item.get_meta("tag") == "VADDRESSBOOK":
tag = ET.Element(_tag("CR", "addressbook")) tag = ET.Element(_tag("CR", "addressbook"))
element.append(tag) element.append(tag)
@ -829,7 +825,6 @@ def report(base_prefix, path, xml_request, collection):
[prop.tag for prop in prop_element] [prop.tag for prop in prop_element]
if prop_element is not None else []) if prop_element is not None else [])
if collection:
if root.tag in ( if root.tag in (
_tag("C", "calendar-multiget"), _tag("C", "calendar-multiget"),
_tag("CR", "addressbook-multiget")): _tag("CR", "addressbook-multiget")):
@ -848,8 +843,6 @@ def report(base_prefix, path, xml_request, collection):
filters = ( filters = (
root.findall(".//%s" % _tag("C", "filter")) + root.findall(".//%s" % _tag("C", "filter")) +
root.findall(".//%s" % _tag("CR", "filter"))) root.findall(".//%s" % _tag("CR", "filter")))
else:
hreferences = filters = ()
multistatus = ET.Element(_tag("D", "multistatus")) multistatus = ET.Element(_tag("D", "multistatus"))