Cosmetics

This commit is contained in:
Guillaume Ayoub 2016-08-01 12:50:51 +02:00
parent 711ecf5df2
commit 6bfdcbafec
7 changed files with 8 additions and 7 deletions

View File

@ -37,7 +37,6 @@ import ssl
import threading import threading
import subprocess import subprocess
import wsgiref.simple_server import wsgiref.simple_server
import re
import zlib import zlib
from http import client from http import client
from urllib.parse import unquote, urlparse from urllib.parse import unquote, urlparse

View File

@ -159,7 +159,7 @@ class Auth(BaseAuth):
""" """
hash_value = hash_value.replace( hash_value = hash_value.replace(
"{SSHA}", "").encode("ascii").decode('base64') "{SSHA}", "").encode("ascii").decode("base64")
password = password.encode(self.configuration.get("encoding", "stock")) password = password.encode(self.configuration.get("encoding", "stock"))
hash_value = hash_value[:20] hash_value = hash_value[:20]
salt_value = hash_value[20:] salt_value = hash_value[20:]

View File

@ -45,7 +45,7 @@ def start(name="radicale", filename=None, debug=False):
# Configuration taken from file # Configuration taken from file
configure_from_file(logger, filename, debug) configure_from_file(logger, filename, debug)
# Reload config on SIGHUP (UNIX only) # Reload config on SIGHUP (UNIX only)
if hasattr(signal, 'SIGHUP'): if hasattr(signal, "SIGHUP"):
def handler_generator(logger, filename, debug): def handler_generator(logger, filename, debug):
def handler(signum, frame): def handler(signum, frame):
configure_from_file(logger, filename, debug) configure_from_file(logger, filename, debug)

View File

@ -104,7 +104,7 @@ class Rights(BaseRights):
self.rights_type = configuration.get("rights", "type").lower() self.rights_type = configuration.get("rights", "type").lower()
def authorized(self, user, collection, permission): def authorized(self, user, collection, permission):
user = user or '' user = user or ""
if user and not storage.is_safe_path_component(user): if user and not storage.is_safe_path_component(user):
# Prevent usernames like "user/calendar.ics" # Prevent usernames like "user/calendar.ics"
raise ValueError("Unsafe username") raise ValueError("Unsafe username")

View File

@ -402,6 +402,7 @@ class Collection(BaseCollection):
if not tag and collection: if not tag and collection:
tag = collection[0].name tag = collection[0].name
self = cls(href) self = cls(href)
if tag == "VCALENDAR": if tag == "VCALENDAR":
self.set_meta("tag", "VCALENDAR") self.set_meta("tag", "VCALENDAR")
if collection: if collection:
@ -411,7 +412,7 @@ class Collection(BaseCollection):
items.extend(getattr(collection, "%s_list" % content, [])) items.extend(getattr(collection, "%s_list" % content, []))
def get_uid(item): def get_uid(item):
return hasattr(item, 'uid') and item.uid.value return hasattr(item, "uid") and item.uid.value
items_by_uid = groupby( items_by_uid = groupby(
sorted(items, key=get_uid), get_uid) sorted(items, key=get_uid), get_uid)
@ -429,6 +430,7 @@ class Collection(BaseCollection):
for card in collection: for card in collection:
file_name = hex(getrandbits(32))[2:] file_name = hex(getrandbits(32))[2:]
self.upload(file_name, card) self.upload(file_name, card)
return self return self
def list(self): def list(self):

View File

@ -28,4 +28,4 @@ from radicale import auth
class Auth(auth.BaseAuth): class Auth(auth.BaseAuth):
def is_authenticated(self, user, password): def is_authenticated(self, user, password):
return user == 'tmp' return user == "tmp"

View File

@ -778,7 +778,7 @@ def proppatch(path, xml_request, collection):
_add_propstat_to(response, short_name, 200) _add_propstat_to(response, short_name, 200)
for short_name in props_to_remove: for short_name in props_to_remove:
collection.set_meta(short_name, '') collection.set_meta(short_name, "")
_add_propstat_to(response, short_name, 200) _add_propstat_to(response, short_name, 200)
return _pretty_xml(multistatus) return _pretty_xml(multistatus)