refac: deprecation fix

This commit is contained in:
Jörn-Michael Miehe 2023-10-26 18:50:04 +02:00
parent 9551ee7729
commit 0a5f84eee5
2 changed files with 12 additions and 31 deletions

View file

@ -3,8 +3,7 @@ from datetime import datetime, timedelta
from asyncify import asyncify from asyncify import asyncify
from cache import AsyncTTL from cache import AsyncTTL
from caldav import Calendar, DAVClient, Principal from caldav import Calendar, DAVClient, Event, Principal
from caldav.lib.error import ReportError
from vobject.base import Component from vobject.base import Component
from .calevent import CalEvent from .calevent import CalEvent
@ -28,7 +27,6 @@ class CalDAV:
Gets the `Principal` object of the main CalDAV client. Gets the `Principal` object of the main CalDAV client.
""" """
_logger.debug("principal")
return cls._caldav_client.principal() return cls._caldav_client.principal()
@classmethod @classmethod
@ -83,21 +81,12 @@ class CalDAV:
dt_start = datetime.combine(date_start, time_min) dt_start = datetime.combine(date_start, time_min)
dt_end = dt_start + search_span dt_end = dt_start + search_span
try: search_result = calendar.search(
search_result = calendar.date_search(
start=dt_start, start=dt_start,
end=dt_end, end=dt_end,
expand=True, expand=True,
verify_expand=True, comp_class=Event,
) split_expanded=False,
except ReportError:
_logger.warning("CalDAV server does not support expanded search")
search_result = calendar.date_search(
start=dt_start,
end=dt_end,
expand=False,
) )
vevents = [] vevents = []

View file

@ -7,9 +7,7 @@ from fastapi import Depends, HTTPException, params, status
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
_RESPONSE_OK = { _RESPONSE_OK = {
status.HTTP_200_OK: { status.HTTP_200_OK: {"description": "Operation successful"},
"description": "Operation successful",
},
} }
Params = ParamSpec("Params") Params = ParamSpec("Params")
@ -39,7 +37,7 @@ class ListManager:
if isinstance(names, params.Depends): if isinstance(names, params.Depends):
names = await lister.func() names = await lister.func()
_logger.debug("filter %s from %s", repr(prefix), repr(names)) # _logger.debug("filter %s from %s", repr(prefix), repr(names))
return [item for item in names if item.lower().startswith(prefix.lower())] return [item for item in names if item.lower().startswith(prefix.lower())]
@ -69,14 +67,8 @@ class ListManager:
func=_getter_fn, func=_getter_fn,
responses={ responses={
**_RESPONSE_OK, **_RESPONSE_OK,
status.HTTP_404_NOT_FOUND: { status.HTTP_404_NOT_FOUND: {"description": "Prefix not found"},
"description": "Prefix not found", status.HTTP_409_CONFLICT: {"description": "Ambiguous prefix"},
"content": None,
},
status.HTTP_409_CONFLICT: {
"description": "Ambiguous prefix",
"content": None,
},
}, },
), ),
) )