From d1ceb620e4d416250c5218bfd0d2bb6de72af11e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dipl=2E=20Ing=2E=20P=C3=A9ter=20Varkoly?= Date: Sun, 22 Sep 2024 18:38:21 +0200 Subject: [PATCH] Adapt function template discovery to the implementation --- radicale/rights/from_file.py | 4 ++-- radicale/storage/__init__.py | 8 ++++++-- radicale/storage/multifilesystem/discover.py | 9 +++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/radicale/rights/from_file.py b/radicale/rights/from_file.py index 0b5e9093..20928a64 100644 --- a/radicale/rights/from_file.py +++ b/radicale/rights/from_file.py @@ -66,8 +66,8 @@ class Rights(rights.BaseRights): if not self._log_rights_rule_doesnt_match_on_debug: logger.debug("logging of rules which doesn't match suppressed by config/option [logging] rights_rule_doesnt_match_on_debug") for section in self._rights_config.sections(): - group_match = False - user_match = False + group_match = None + user_match = None try: user_pattern = self._rights_config.get(section, "user", fallback="") collection_pattern = self._rights_config.get(section, "collection") diff --git a/radicale/storage/__init__.py b/radicale/storage/__init__.py index 6946f59b..f034b337 100644 --- a/radicale/storage/__init__.py +++ b/radicale/storage/__init__.py @@ -24,6 +24,7 @@ Take a look at the class ``BaseCollection`` if you want to implement your own. """ import json +from typing import Callable, ContextManager, Iterator, Optional, Set, cast import xml.etree.ElementTree as ET from hashlib import sha256 from typing import (Iterable, Iterator, Mapping, Optional, Sequence, Set, @@ -282,8 +283,11 @@ class BaseStorage: """ self.configuration = configuration - def discover(self, path: str, depth: str = "0") -> Iterable[ - "types.CollectionOrItem"]: + def discover( + self, path: str, depth: str = "0", + child_context_manager: Optional[ + Callable[[str, Optional[str]], ContextManager[None]]] = None, + user_groups: Set[str] = set([])) -> Iterable["types.CollectionOrItem"]: """Discover a list of collections under the given ``path``. ``path`` is sanitized. diff --git a/radicale/storage/multifilesystem/discover.py b/radicale/storage/multifilesystem/discover.py index 9a951764..97d31930 100644 --- a/radicale/storage/multifilesystem/discover.py +++ b/radicale/storage/multifilesystem/discover.py @@ -19,7 +19,7 @@ import os import posixpath import base64 -from typing import Callable, ContextManager, Iterator, Optional, cast +from typing import Callable, ContextManager, Iterator, Optional, Set, cast from radicale import pathutils, types from radicale.log import logger @@ -36,9 +36,10 @@ def _null_child_context_manager(path: str, class StoragePartDiscover(StorageBase): def discover( - self, path: str, depth: str = "0", child_context_manager: Optional[ - Callable[[str, Optional[str]], ContextManager[None]]] = None, - user_groups: Set[str] = set([]) + self, path: str, depth: str = "0", + child_context_manager: Optional[ + Callable[[str, Optional[str]], ContextManager[None]]] = None, + user_groups: Set[str] = set([]) ) -> Iterator[types.CollectionOrItem]: # assert isinstance(self, multifilesystem.Storage) if child_context_manager is None: