Cosmetic changes
This commit is contained in:
parent
e07df9fd1d
commit
866aa34f54
@ -58,11 +58,10 @@ def run():
|
|||||||
if option.startswith("_"):
|
if option.startswith("_"):
|
||||||
continue
|
continue
|
||||||
kwargs = data.copy()
|
kwargs = data.copy()
|
||||||
long_name = "--{0}-{1}".format(
|
long_name = "--%s-%s" % (section, option.replace("_", "-"))
|
||||||
section, option.replace("_", "-"))
|
|
||||||
args = kwargs.pop("aliases", [])
|
args = kwargs.pop("aliases", [])
|
||||||
args.append(long_name)
|
args.append(long_name)
|
||||||
kwargs["dest"] = "{0}_{1}".format(section, option)
|
kwargs["dest"] = "%s_%s" % (section, option)
|
||||||
groups[group].append(kwargs["dest"])
|
groups[group].append(kwargs["dest"])
|
||||||
del kwargs["value"]
|
del kwargs["value"]
|
||||||
if "internal" in kwargs:
|
if "internal" in kwargs:
|
||||||
@ -73,11 +72,11 @@ def run():
|
|||||||
kwargs["action"] = "store_const"
|
kwargs["action"] = "store_const"
|
||||||
kwargs["const"] = "True"
|
kwargs["const"] = "True"
|
||||||
opposite_args = kwargs.pop("opposite", [])
|
opposite_args = kwargs.pop("opposite", [])
|
||||||
opposite_args.append("--no{0}".format(long_name[1:]))
|
opposite_args.append("--no%s" % long_name[1:])
|
||||||
group.add_argument(*args, **kwargs)
|
group.add_argument(*args, **kwargs)
|
||||||
|
|
||||||
kwargs["const"] = "False"
|
kwargs["const"] = "False"
|
||||||
kwargs["help"] = "do not {0} (opposite of {1})".format(
|
kwargs["help"] = "do not %s (opposite of %s)" % (
|
||||||
kwargs["help"], long_name)
|
kwargs["help"], long_name)
|
||||||
group.add_argument(*opposite_args, **kwargs)
|
group.add_argument(*opposite_args, **kwargs)
|
||||||
else:
|
else:
|
||||||
|
@ -195,7 +195,7 @@ def get_etag(text):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
etag = sha256()
|
etag = sha256()
|
||||||
etag.update(text.encode("utf-8"))
|
etag.update(text.encode())
|
||||||
return '"%s"' % etag.hexdigest()
|
return '"%s"' % etag.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ class BaseCollection:
|
|||||||
"""Encoded as quoted-string (see RFC 2616)."""
|
"""Encoded as quoted-string (see RFC 2616)."""
|
||||||
etag = sha256()
|
etag = sha256()
|
||||||
for item in self.get_all():
|
for item in self.get_all():
|
||||||
etag.update((item.href + "/" + item.etag).encode("utf-8"))
|
etag.update((item.href + "/" + item.etag).encode())
|
||||||
etag.update(json.dumps(self.get_meta(), sort_keys=True).encode())
|
etag.update(json.dumps(self.get_meta(), sort_keys=True).encode())
|
||||||
return '"%s"' % etag.hexdigest()
|
return '"%s"' % etag.hexdigest()
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class CollectionSyncMixin:
|
|||||||
((href, None) for href in self._get_deleted_history_hrefs())):
|
((href, None) for href in self._get_deleted_history_hrefs())):
|
||||||
history_etag = self._update_history_etag(href, item)
|
history_etag = self._update_history_etag(href, item)
|
||||||
state[href] = history_etag
|
state[href] = history_etag
|
||||||
token_name_hash.update((href + "/" + history_etag).encode("utf-8"))
|
token_name_hash.update((href + "/" + history_etag).encode())
|
||||||
token_name = token_name_hash.hexdigest()
|
token_name = token_name_hash.hexdigest()
|
||||||
token = "http://radicale.org/ns/sync/%s" % token_name
|
token = "http://radicale.org/ns/sync/%s" % token_name
|
||||||
if token_name == old_token_name:
|
if token_name == old_token_name:
|
||||||
|
@ -62,7 +62,7 @@ class BaseTest:
|
|||||||
args["REQUEST_METHOD"] = method.upper()
|
args["REQUEST_METHOD"] = method.upper()
|
||||||
args["PATH_INFO"] = path
|
args["PATH_INFO"] = path
|
||||||
if data:
|
if data:
|
||||||
data = data.encode("utf-8")
|
data = data.encode()
|
||||||
args["wsgi.input"] = BytesIO(data)
|
args["wsgi.input"] = BytesIO(data)
|
||||||
args["CONTENT_LENGTH"] = str(len(data))
|
args["CONTENT_LENGTH"] = str(len(data))
|
||||||
args["wsgi.errors"] = sys.stderr
|
args["wsgi.errors"] = sys.stderr
|
||||||
@ -75,4 +75,4 @@ class BaseTest:
|
|||||||
answer = self.application(args, start_response)
|
answer = self.application(args, start_response)
|
||||||
|
|
||||||
return (int(status.split()[0]), dict(headers),
|
return (int(status.split()[0]), dict(headers),
|
||||||
answer[0].decode("utf-8") if answer else None)
|
answer[0].decode() if answer else None)
|
||||||
|
@ -444,20 +444,19 @@ class BaseRequestsMixIn:
|
|||||||
assert answer.count("BEGIN:VEVENT") == 2
|
assert answer.count("BEGIN:VEVENT") == 2
|
||||||
|
|
||||||
def _test_filter(self, filters, kind="event", test=None, items=(1,)):
|
def _test_filter(self, filters, kind="event", test=None, items=(1,)):
|
||||||
filter_template = "<C:filter>{}</C:filter>"
|
filter_template = "<C:filter>%s</C:filter>"
|
||||||
if kind in ("event", "journal", "todo"):
|
if kind in ("event", "journal", "todo"):
|
||||||
create_collection_fn = partial(self.request, "MKCALENDAR")
|
create_collection_fn = partial(self.request, "MKCALENDAR")
|
||||||
path = "/calendar.ics/"
|
path = "/calendar.ics/"
|
||||||
filename_template = "{}{}.ics"
|
filename_template = "%s%d.ics"
|
||||||
namespace = "urn:ietf:params:xml:ns:caldav"
|
namespace = "urn:ietf:params:xml:ns:caldav"
|
||||||
report = "calendar-query"
|
report = "calendar-query"
|
||||||
elif kind == "contact":
|
elif kind == "contact":
|
||||||
create_collection_fn = self._create_addressbook
|
create_collection_fn = self._create_addressbook
|
||||||
if test:
|
if test:
|
||||||
filter_template = '<C:filter test="{}">{{}}</C:filter>'.format(
|
filter_template = '<C:filter test="%s">%%s</C:filter>' % test
|
||||||
test)
|
|
||||||
path = "/contacts.vcf/"
|
path = "/contacts.vcf/"
|
||||||
filename_template = "{}{}.vcf"
|
filename_template = "%s%d.vcf"
|
||||||
namespace = "urn:ietf:params:xml:ns:carddav"
|
namespace = "urn:ietf:params:xml:ns:carddav"
|
||||||
report = "addressbook-query"
|
report = "addressbook-query"
|
||||||
else:
|
else:
|
||||||
@ -467,13 +466,12 @@ class BaseRequestsMixIn:
|
|||||||
status, _, _ = create_collection_fn(path)
|
status, _, _ = create_collection_fn(path)
|
||||||
assert status == 201
|
assert status == 201
|
||||||
for i in items:
|
for i in items:
|
||||||
filename = filename_template.format(kind, i)
|
filename = filename_template % (kind, i)
|
||||||
event = get_file_content(filename)
|
event = get_file_content(filename)
|
||||||
status, _, _ = self.request(
|
status, _, _ = self.request(
|
||||||
"PUT", posixpath.join(path, filename), event)
|
"PUT", posixpath.join(path, filename), event)
|
||||||
assert status == 201
|
assert status == 201
|
||||||
filters_text = "".join(
|
filters_text = "".join(filter_template % f for f in filters)
|
||||||
filter_template.format(filter_) for filter_ in filters)
|
|
||||||
status, _, answer = self.request(
|
status, _, answer = self.request(
|
||||||
"REPORT", path,
|
"REPORT", path,
|
||||||
"""<?xml version="1.0" encoding="utf-8" ?>
|
"""<?xml version="1.0" encoding="utf-8" ?>
|
||||||
@ -1350,7 +1348,7 @@ class BaseRequestsMixIn:
|
|||||||
status, _, _ = self.request("MKCALENDAR", "/test/")
|
status, _, _ = self.request("MKCALENDAR", "/test/")
|
||||||
assert status == 201
|
assert status == 201
|
||||||
for component in ("event", "todo", "journal"):
|
for component in ("event", "todo", "journal"):
|
||||||
event = get_file_content("{}1.ics".format(component))
|
event = get_file_content("%s1.ics" % component)
|
||||||
status, _, _ = self.request("DELETE", "/test/test.ics")
|
status, _, _ = self.request("DELETE", "/test/test.ics")
|
||||||
assert status in (200, 404)
|
assert status in (200, 404)
|
||||||
status, _, _ = self.request("PUT", "/test/test.ics", event)
|
status, _, _ = self.request("PUT", "/test/test.ics", event)
|
||||||
@ -1364,7 +1362,7 @@ class BaseRequestsMixIn:
|
|||||||
</D:prop>
|
</D:prop>
|
||||||
</C:calendar-query>""")
|
</C:calendar-query>""")
|
||||||
assert status == 207
|
assert status == 207
|
||||||
assert ">text/calendar;charset=utf-8;component=V{}<".format(
|
assert ">text/calendar;charset=utf-8;component=V%s<" % (
|
||||||
component.upper()) in answer
|
component.upper()) in answer
|
||||||
|
|
||||||
def test_addressbook_getcontenttype(self):
|
def test_addressbook_getcontenttype(self):
|
||||||
|
@ -151,11 +151,10 @@ class TestBaseServerRequests:
|
|||||||
for option, data in values.items():
|
for option, data in values.items():
|
||||||
if option.startswith("_"):
|
if option.startswith("_"):
|
||||||
continue
|
continue
|
||||||
long_name = "--{0}-{1}".format(
|
long_name = "--%s-%s" % (section, option.replace("_", "-"))
|
||||||
section, option.replace("_", "-"))
|
|
||||||
if data["type"] == bool:
|
if data["type"] == bool:
|
||||||
if not self.configuration.get(section, option):
|
if not self.configuration.get(section, option):
|
||||||
long_name = "--no{0}".format(long_name[1:])
|
long_name = "--no%s" % long_name[1:]
|
||||||
config_args.append(long_name)
|
config_args.append(long_name)
|
||||||
else:
|
else:
|
||||||
config_args.append(long_name)
|
config_args.append(long_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user