Cosmetic changes
This commit is contained in:
parent
fc180266d5
commit
db7587c593
@ -28,6 +28,7 @@ import contextlib
|
||||
import os
|
||||
import signal
|
||||
import socket
|
||||
import sys
|
||||
|
||||
from radicale import VERSION, config, log, server, storage
|
||||
from radicale.log import logger
|
||||
@ -113,7 +114,7 @@ def run():
|
||||
configuration.update(arguments_config, "arguments")
|
||||
except Exception as e:
|
||||
logger.fatal("Invalid configuration: %s", e, exc_info=True)
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
# Configure logging
|
||||
log.set_level(configuration.get("logging", "level"))
|
||||
@ -128,11 +129,11 @@ def run():
|
||||
with storage_.acquire_lock("r"):
|
||||
if not storage_.verify():
|
||||
logger.fatal("Storage verifcation failed")
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
logger.fatal("An exception occurred during storage verification: "
|
||||
"%s", e, exc_info=True)
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
return
|
||||
|
||||
# Create a socket pair to notify the server of program shutdown
|
||||
@ -149,7 +150,7 @@ def run():
|
||||
except Exception as e:
|
||||
logger.fatal("An exception occurred during server startup: %s", e,
|
||||
exc_info=True)
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -450,8 +450,7 @@ def text_match(vobject_item, filter_, child_name, ns, attrib_name=None):
|
||||
condition = any(match(child.value) for child in children)
|
||||
if filter_.get("negate-condition") == "yes":
|
||||
return not condition
|
||||
else:
|
||||
return condition
|
||||
return condition
|
||||
|
||||
|
||||
def param_filter_match(vobject_item, filter_, parent_name, ns):
|
||||
@ -467,10 +466,9 @@ def param_filter_match(vobject_item, filter_, parent_name, ns):
|
||||
if filter_[0].tag == xmlutils.make_clark("%s:text-match" % ns):
|
||||
return condition and text_match(
|
||||
vobject_item, filter_[0], parent_name, ns, name)
|
||||
elif filter_[0].tag == xmlutils.make_clark("%s:is-not-defined" % ns):
|
||||
if filter_[0].tag == xmlutils.make_clark("%s:is-not-defined" % ns):
|
||||
return not condition
|
||||
else:
|
||||
return condition
|
||||
return condition
|
||||
|
||||
|
||||
def simplify_prefilters(filters, collection_tag="VCALENDAR"):
|
||||
|
@ -77,9 +77,8 @@ class Rights(rights.BaseRights):
|
||||
collection_pattern, section)
|
||||
return rights.intersect_permissions(
|
||||
permissions, rights_config.get(section, "permissions"))
|
||||
else:
|
||||
logger.debug("Rule %r:%r doesn't match %r:%r from section %r",
|
||||
user, sane_path, user_pattern,
|
||||
collection_pattern, section)
|
||||
logger.debug("Rule %r:%r doesn't match %r:%r from section %r",
|
||||
user, sane_path, user_pattern, collection_pattern,
|
||||
section)
|
||||
logger.info("Rights: %r:%r doesn't match any section", user, sane_path)
|
||||
return ""
|
||||
|
@ -240,7 +240,7 @@ class BaseCollection:
|
||||
return (template[:template_insert_pos] +
|
||||
vtimezones + components +
|
||||
template[template_insert_pos:])
|
||||
elif self.get_meta("tag") == "VADDRESSBOOK":
|
||||
if self.get_meta("tag") == "VADDRESSBOOK":
|
||||
return "".join((item.serialize() for item in self.get_all()))
|
||||
return ""
|
||||
|
||||
|
@ -53,7 +53,8 @@ class CollectionCacheMixin:
|
||||
if modified:
|
||||
self._storage._sync_directory(folder)
|
||||
|
||||
def _item_cache_hash(self, raw_text):
|
||||
@staticmethod
|
||||
def _item_cache_hash(raw_text):
|
||||
_hash = sha256()
|
||||
_hash.update(storage.CACHE_VERSION)
|
||||
_hash.update(raw_text)
|
||||
|
@ -84,10 +84,9 @@ class TestBaseAuthRequests(BaseTest):
|
||||
("😁", "🔑", False), ("😀", "", False),
|
||||
("", "🔑", False), ("", "", False))
|
||||
for user, password, valid in test_matrix:
|
||||
status, _ = self.propfind(
|
||||
"/", check=207 if valid else 401, HTTP_AUTHORIZATION=(
|
||||
"Basic %s" % base64.b64encode(
|
||||
("%s:%s" % (user, password)).encode()).decode()))
|
||||
self.propfind("/", check=207 if valid else 401,
|
||||
HTTP_AUTHORIZATION=("Basic %s" % base64.b64encode(
|
||||
("%s:%s" % (user, password)).encode()).decode()))
|
||||
|
||||
def test_htpasswd_plain(self):
|
||||
self._test_htpasswd("plain", "tmp:bepo")
|
||||
|
@ -54,25 +54,24 @@ for short, url in NAMESPACES.items():
|
||||
ET.register_namespace("" if short == "D" else short, url)
|
||||
|
||||
|
||||
def pretty_xml(element, level=0):
|
||||
def pretty_xml(element):
|
||||
"""Indent an ElementTree ``element`` and its children."""
|
||||
if not level:
|
||||
element = copy.deepcopy(element)
|
||||
i = "\n" + level * " "
|
||||
if len(element) > 0:
|
||||
if not element.text or not element.text.strip():
|
||||
element.text = i + " "
|
||||
if not element.tail or not element.tail.strip():
|
||||
element.tail = i
|
||||
for sub_element in element:
|
||||
pretty_xml(sub_element, level + 1)
|
||||
if not sub_element.tail or not sub_element.tail.strip():
|
||||
sub_element.tail = i
|
||||
else:
|
||||
if level and (not element.tail or not element.tail.strip()):
|
||||
element.tail = i
|
||||
if not level:
|
||||
return '<?xml version="1.0"?>\n%s' % ET.tostring(element, "unicode")
|
||||
def pretty_xml_recursive(element, level):
|
||||
indent = "\n" + level * " "
|
||||
if len(element) > 0:
|
||||
if not (element.text or "").strip():
|
||||
element.text = indent + " "
|
||||
if not (element.tail or "").strip():
|
||||
element.tail = indent
|
||||
for sub_element in element:
|
||||
pretty_xml_recursive(sub_element, level + 1)
|
||||
if not (sub_element.tail or "").strip():
|
||||
sub_element.tail = indent
|
||||
elif level > 0 and not (element.tail or "").strip():
|
||||
element.tail = indent
|
||||
element = copy.deepcopy(element)
|
||||
pretty_xml_recursive(element, 0)
|
||||
return '<?xml version="1.0"?>\n%s' % ET.tostring(element, "unicode")
|
||||
|
||||
|
||||
def make_clark(human_tag):
|
||||
@ -168,7 +167,7 @@ def props_from_request(xml_request, actions=("set", "remove")):
|
||||
if resource_type.tag == make_clark("C:calendar"):
|
||||
result["tag"] = "VCALENDAR"
|
||||
break
|
||||
elif resource_type.tag == make_clark("CR:addressbook"):
|
||||
if resource_type.tag == make_clark("CR:addressbook"):
|
||||
result["tag"] = "VADDRESSBOOK"
|
||||
break
|
||||
elif prop.tag == make_clark("C:supported-calendar-component-set"):
|
||||
|
Loading…
Reference in New Issue
Block a user