1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-06-26 16:45:52 +00:00

Adapt function template discovery to the implementation

This commit is contained in:
Dipl. Ing. Péter Varkoly 2024-09-22 18:38:21 +02:00
parent 040a433696
commit d1ceb620e4
3 changed files with 13 additions and 8 deletions

View file

@ -66,8 +66,8 @@ class Rights(rights.BaseRights):
if not self._log_rights_rule_doesnt_match_on_debug: 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") 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(): for section in self._rights_config.sections():
group_match = False group_match = None
user_match = False user_match = None
try: try:
user_pattern = self._rights_config.get(section, "user", fallback="") user_pattern = self._rights_config.get(section, "user", fallback="")
collection_pattern = self._rights_config.get(section, "collection") collection_pattern = self._rights_config.get(section, "collection")

View file

@ -24,6 +24,7 @@ Take a look at the class ``BaseCollection`` if you want to implement your own.
""" """
import json import json
from typing import Callable, ContextManager, Iterator, Optional, Set, cast
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
from hashlib import sha256 from hashlib import sha256
from typing import (Iterable, Iterator, Mapping, Optional, Sequence, Set, from typing import (Iterable, Iterator, Mapping, Optional, Sequence, Set,
@ -282,8 +283,11 @@ class BaseStorage:
""" """
self.configuration = configuration self.configuration = configuration
def discover(self, path: str, depth: str = "0") -> Iterable[ def discover(
"types.CollectionOrItem"]: 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``. """Discover a list of collections under the given ``path``.
``path`` is sanitized. ``path`` is sanitized.

View file

@ -19,7 +19,7 @@
import os import os
import posixpath import posixpath
import base64 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 import pathutils, types
from radicale.log import logger from radicale.log import logger
@ -36,9 +36,10 @@ def _null_child_context_manager(path: str,
class StoragePartDiscover(StorageBase): class StoragePartDiscover(StorageBase):
def discover( def discover(
self, path: str, depth: str = "0", child_context_manager: Optional[ self, path: str, depth: str = "0",
Callable[[str, Optional[str]], ContextManager[None]]] = None, child_context_manager: Optional[
user_groups: Set[str] = set([]) Callable[[str, Optional[str]], ContextManager[None]]] = None,
user_groups: Set[str] = set([])
) -> Iterator[types.CollectionOrItem]: ) -> Iterator[types.CollectionOrItem]:
# assert isinstance(self, multifilesystem.Storage) # assert isinstance(self, multifilesystem.Storage)
if child_context_manager is None: if child_context_manager is None: