mirror of
https://github.com/Kozea/Radicale.git
synced 2025-06-26 16:45:52 +00:00
Style fixes for tox linting
This commit is contained in:
parent
29b7cd8d54
commit
d6c0a05771
5 changed files with 26 additions and 14 deletions
|
@ -23,26 +23,31 @@ import datetime
|
|||
import posixpath
|
||||
import socket
|
||||
import xml.etree.ElementTree as ET
|
||||
import vobject
|
||||
from http import client
|
||||
from typing import (Any, Callable, Iterable, Iterator, List, Optional,
|
||||
Sequence, Tuple, Union)
|
||||
from urllib.parse import unquote, urlparse
|
||||
|
||||
import vobject
|
||||
import vobject.base
|
||||
from vobject.base import ContentLine
|
||||
|
||||
import radicale.item as radicale_item
|
||||
from radicale import httputils, pathutils, storage, types, xmlutils, config
|
||||
from radicale import httputils, pathutils, storage, types, xmlutils
|
||||
from radicale.app.base import Access, ApplicationBase
|
||||
from radicale.item import filter as radicale_filter
|
||||
from radicale.log import logger
|
||||
|
||||
|
||||
def free_busy_report(base_prefix: str, path: str, xml_request: Optional[ET.Element],
|
||||
collection: storage.BaseCollection, encoding: str,
|
||||
unlock_storage_fn: Callable[[], None],
|
||||
max_occurrence: int
|
||||
) -> Tuple[int, str]:
|
||||
) -> Tuple[int, Union[ET.Element, str]]:
|
||||
# NOTE: this function returns both an Element and a string because
|
||||
# free-busy reports are an edge-case on the return type according
|
||||
# to the spec.
|
||||
|
||||
multistatus = ET.Element(xmlutils.make_clark("D:multistatus"))
|
||||
if xml_request is None:
|
||||
return client.MULTI_STATUS, multistatus
|
||||
|
@ -54,6 +59,7 @@ def free_busy_report(base_prefix: str, path: str, xml_request: Optional[ET.Eleme
|
|||
return client.FORBIDDEN, xmlutils.webdav_error("D:supported-report")
|
||||
|
||||
time_range_element = root.find(xmlutils.make_clark("C:time-range"))
|
||||
assert isinstance(time_range_element, ET.Element)
|
||||
|
||||
# Build a single filter from the free busy query for retrieval
|
||||
# TODO: filter for VFREEBUSY in additional to VEVENT but
|
||||
|
@ -525,7 +531,7 @@ class ApplicationPartReport(ApplicationBase):
|
|||
"Bad REPORT request on %r: %s", path, e, exc_info=True)
|
||||
return httputils.BAD_REQUEST
|
||||
headers = {"Content-Type": "text/calendar; charset=%s" % self._encoding}
|
||||
return status, headers, body
|
||||
return status, headers, str(body)
|
||||
else:
|
||||
try:
|
||||
status, xml_answer = xml_report(
|
||||
|
|
|
@ -301,6 +301,7 @@ DEFAULT_CONFIG_SCHEMA: types.CONFIG_SCHEMA = OrderedDict([
|
|||
"type": positive_int})]))
|
||||
])
|
||||
|
||||
|
||||
def parse_compound_paths(*compound_paths: Optional[str]
|
||||
) -> List[Tuple[str, bool]]:
|
||||
"""Parse a compound path and return the individual paths.
|
||||
|
|
|
@ -70,10 +70,12 @@ def parse_time_range(time_filter: ET.Element) -> Tuple[datetime, datetime]:
|
|||
end = DATETIME_MAX
|
||||
return start, end
|
||||
|
||||
|
||||
def time_range_timestamps(time_filter: ET.Element) -> Tuple[int, int]:
|
||||
start, end = parse_time_range(time_filter)
|
||||
return (math.floor(start.timestamp()), math.ceil(end.timestamp()))
|
||||
|
||||
|
||||
def comp_match(item: "item.Item", filter_: ET.Element, level: int = 0) -> bool:
|
||||
"""Check whether the ``item`` matches the comp ``filter_``.
|
||||
|
||||
|
@ -202,6 +204,7 @@ def time_range_fill(vobject_item: vobject.base.Component,
|
|||
|
||||
start, end = parse_time_range(filter_)
|
||||
ranges: List[Tuple[datetime, datetime]] = []
|
||||
|
||||
def range_fn(range_start: datetime, range_end: datetime,
|
||||
is_recurrence: bool) -> bool:
|
||||
nonlocal ranges
|
||||
|
|
|
@ -27,11 +27,11 @@ import sys
|
|||
import tempfile
|
||||
import wsgiref.util
|
||||
import xml.etree.ElementTree as ET
|
||||
import vobject
|
||||
from io import BytesIO
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
import defusedxml.ElementTree as DefusedET
|
||||
import vobject
|
||||
|
||||
import radicale
|
||||
from radicale import app, config, types, xmlutils
|
||||
|
|
|
@ -22,10 +22,10 @@ Radicale tests with simple requests.
|
|||
|
||||
import os
|
||||
import posixpath
|
||||
import vobject
|
||||
from typing import Any, Callable, ClassVar, Iterable, List, Optional, Tuple
|
||||
|
||||
import defusedxml.ElementTree as DefusedET
|
||||
import vobject
|
||||
|
||||
from radicale import storage, xmlutils
|
||||
from radicale.tests import RESPONSES, BaseTest
|
||||
|
@ -1382,12 +1382,14 @@ permissions: RrWw""")
|
|||
assert isinstance(response, vobject.base.Component)
|
||||
assert len(responses) == 1
|
||||
vcalendar = list(responses.values())[0]
|
||||
assert isinstance(vcalendar, vobject.base.Component)
|
||||
assert len(vcalendar.vfreebusy_list) == 3
|
||||
types = {}
|
||||
for vfb in vcalendar.vfreebusy_list:
|
||||
if vfb.fbtype.value not in types:
|
||||
types[vfb.fbtype.value] = 0
|
||||
types[vfb.fbtype.value] += 1
|
||||
fbtype_val = vfb.fbtype.value
|
||||
if fbtype_val not in types:
|
||||
types[fbtype_val] = 0
|
||||
types[fbtype_val] += 1
|
||||
assert types == {'BUSY': 2, 'FREE': 1}
|
||||
|
||||
def _report_sync_token(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue