From 0a5f84eee553015cdedcc13e02508b6dc7032b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Thu, 26 Oct 2023 18:50:04 +0200 Subject: [PATCH] refac: deprecation fix --- api/ovdashboard_api/core/caldav.py | 27 ++++++------------- .../routers/v1/_list_manager.py | 16 +++-------- 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/api/ovdashboard_api/core/caldav.py b/api/ovdashboard_api/core/caldav.py index bd885b4..26d42fe 100644 --- a/api/ovdashboard_api/core/caldav.py +++ b/api/ovdashboard_api/core/caldav.py @@ -3,8 +3,7 @@ from datetime import datetime, timedelta from asyncify import asyncify from cache import AsyncTTL -from caldav import Calendar, DAVClient, Principal -from caldav.lib.error import ReportError +from caldav import Calendar, DAVClient, Event, Principal from vobject.base import Component from .calevent import CalEvent @@ -28,7 +27,6 @@ class CalDAV: Gets the `Principal` object of the main CalDAV client. """ - _logger.debug("principal") return cls._caldav_client.principal() @classmethod @@ -83,22 +81,13 @@ class CalDAV: dt_start = datetime.combine(date_start, time_min) dt_end = dt_start + search_span - try: - search_result = calendar.date_search( - start=dt_start, - end=dt_end, - expand=True, - verify_expand=True, - ) - - except ReportError: - _logger.warning("CalDAV server does not support expanded search") - - search_result = calendar.date_search( - start=dt_start, - end=dt_end, - expand=False, - ) + search_result = calendar.search( + start=dt_start, + end=dt_end, + expand=True, + comp_class=Event, + split_expanded=False, + ) vevents = [] for event in search_result: diff --git a/api/ovdashboard_api/routers/v1/_list_manager.py b/api/ovdashboard_api/routers/v1/_list_manager.py index b967d34..67bea50 100644 --- a/api/ovdashboard_api/routers/v1/_list_manager.py +++ b/api/ovdashboard_api/routers/v1/_list_manager.py @@ -7,9 +7,7 @@ from fastapi import Depends, HTTPException, params, status _logger = logging.getLogger(__name__) _RESPONSE_OK = { - status.HTTP_200_OK: { - "description": "Operation successful", - }, + status.HTTP_200_OK: {"description": "Operation successful"}, } Params = ParamSpec("Params") @@ -39,7 +37,7 @@ class ListManager: if isinstance(names, params.Depends): 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())] @@ -69,14 +67,8 @@ class ListManager: func=_getter_fn, responses={ **_RESPONSE_OK, - status.HTTP_404_NOT_FOUND: { - "description": "Prefix not found", - "content": None, - }, - status.HTTP_409_CONFLICT: { - "description": "Ambiguous prefix", - "content": None, - }, + status.HTTP_404_NOT_FOUND: {"description": "Prefix not found"}, + status.HTTP_409_CONFLICT: {"description": "Ambiguous prefix"}, }, ), )