From 6bfdcbafece2e5dc803d2dbbf86ce5e1ddd48284 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Mon, 1 Aug 2016 12:50:51 +0200 Subject: [PATCH] Cosmetics --- radicale/__init__.py | 1 - radicale/auth.py | 2 +- radicale/log.py | 2 +- radicale/rights.py | 2 +- radicale/storage.py | 4 +++- radicale/tests/custom/auth.py | 2 +- radicale/xmlutils.py | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index e3d904c..9331821 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -37,7 +37,6 @@ import ssl import threading import subprocess import wsgiref.simple_server -import re import zlib from http import client from urllib.parse import unquote, urlparse diff --git a/radicale/auth.py b/radicale/auth.py index af3117f..ea43f16 100644 --- a/radicale/auth.py +++ b/radicale/auth.py @@ -159,7 +159,7 @@ class Auth(BaseAuth): """ hash_value = hash_value.replace( - "{SSHA}", "").encode("ascii").decode('base64') + "{SSHA}", "").encode("ascii").decode("base64") password = password.encode(self.configuration.get("encoding", "stock")) hash_value = hash_value[:20] salt_value = hash_value[20:] diff --git a/radicale/log.py b/radicale/log.py index 6523593..308e2a4 100644 --- a/radicale/log.py +++ b/radicale/log.py @@ -45,7 +45,7 @@ def start(name="radicale", filename=None, debug=False): # Configuration taken from file configure_from_file(logger, filename, debug) # Reload config on SIGHUP (UNIX only) - if hasattr(signal, 'SIGHUP'): + if hasattr(signal, "SIGHUP"): def handler_generator(logger, filename, debug): def handler(signum, frame): configure_from_file(logger, filename, debug) diff --git a/radicale/rights.py b/radicale/rights.py index b18fed0..1851f7a 100644 --- a/radicale/rights.py +++ b/radicale/rights.py @@ -104,7 +104,7 @@ class Rights(BaseRights): self.rights_type = configuration.get("rights", "type").lower() def authorized(self, user, collection, permission): - user = user or '' + user = user or "" if user and not storage.is_safe_path_component(user): # Prevent usernames like "user/calendar.ics" raise ValueError("Unsafe username") diff --git a/radicale/storage.py b/radicale/storage.py index d53e711..446d7bb 100644 --- a/radicale/storage.py +++ b/radicale/storage.py @@ -402,6 +402,7 @@ class Collection(BaseCollection): if not tag and collection: tag = collection[0].name self = cls(href) + if tag == "VCALENDAR": self.set_meta("tag", "VCALENDAR") if collection: @@ -411,7 +412,7 @@ class Collection(BaseCollection): items.extend(getattr(collection, "%s_list" % content, [])) def get_uid(item): - return hasattr(item, 'uid') and item.uid.value + return hasattr(item, "uid") and item.uid.value items_by_uid = groupby( sorted(items, key=get_uid), get_uid) @@ -429,6 +430,7 @@ class Collection(BaseCollection): for card in collection: file_name = hex(getrandbits(32))[2:] self.upload(file_name, card) + return self def list(self): diff --git a/radicale/tests/custom/auth.py b/radicale/tests/custom/auth.py index a0d9331..30e6e50 100644 --- a/radicale/tests/custom/auth.py +++ b/radicale/tests/custom/auth.py @@ -28,4 +28,4 @@ from radicale import auth class Auth(auth.BaseAuth): def is_authenticated(self, user, password): - return user == 'tmp' + return user == "tmp" diff --git a/radicale/xmlutils.py b/radicale/xmlutils.py index 350dd1b..b57f08d 100644 --- a/radicale/xmlutils.py +++ b/radicale/xmlutils.py @@ -778,7 +778,7 @@ def proppatch(path, xml_request, collection): _add_propstat_to(response, short_name, 200) for short_name in props_to_remove: - collection.set_meta(short_name, '') + collection.set_meta(short_name, "") _add_propstat_to(response, short_name, 200) return _pretty_xml(multistatus)