From b942aeee23e232947fc595cb4682386d7ec794da 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 23:12:51 +0200 Subject: [PATCH] don't use `operator` module --- api/ovdashboard_api/core/caldav.py | 7 +++---- api/ovdashboard_api/core/webdav.py | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/api/ovdashboard_api/core/caldav.py b/api/ovdashboard_api/core/caldav.py index b52d5cb..4f7b97a 100644 --- a/api/ovdashboard_api/core/caldav.py +++ b/api/ovdashboard_api/core/caldav.py @@ -1,6 +1,5 @@ import functools import logging -import operator from datetime import datetime, timedelta from typing import cast @@ -42,7 +41,7 @@ class CalDAV: @property @asyncify @cachedmethod( - cache=operator.attrgetter("_cache"), + cache=lambda cls: cls._cache, key=functools.partial(davkey, "calendars"), ) def calendars(cls) -> list[str]: @@ -56,7 +55,7 @@ class CalDAV: @classmethod @asyncify @cachedmethod( - cache=operator.attrgetter("_cache"), + cache=lambda cls: cls._cache, key=functools.partial(davkey, "get_calendar"), ) def get_calendar(cls, calendar_name: str) -> Calendar: @@ -69,7 +68,7 @@ class CalDAV: @classmethod @asyncify @cachedmethod( - cache=operator.attrgetter("_cache"), + cache=lambda cls: cls._cache, key=functools.partial(davkey, "get_events"), ) def get_events(cls, calendar_name: str, cfg: Config) -> list[CalEvent]: diff --git a/api/ovdashboard_api/core/webdav.py b/api/ovdashboard_api/core/webdav.py index 860685b..305785f 100644 --- a/api/ovdashboard_api/core/webdav.py +++ b/api/ovdashboard_api/core/webdav.py @@ -1,6 +1,5 @@ import functools import logging -import operator import re from io import BytesIO @@ -56,7 +55,7 @@ class WebDAV: @classmethod @asyncify @cachedmethod( - cache=operator.attrgetter("_cache"), + cache=lambda cls: cls._cache, key=functools.partial(davkey, "list_files"), ) def list_files( @@ -77,7 +76,7 @@ class WebDAV: @classmethod @asyncify @cachedmethod( - cache=operator.attrgetter("_cache"), + cache=lambda cls: cls._cache, key=functools.partial(davkey, "exists"), ) def exists(cls, path: str) -> bool: @@ -91,7 +90,7 @@ class WebDAV: @classmethod @asyncify @cachedmethod( - cache=operator.attrgetter("_cache"), + cache=lambda cls: cls._cache, key=functools.partial(davkey, "read_bytes"), ) def read_bytes(cls, path: str) -> bytes: