From 19c6772b8851e7d8e10ee8eec4e06100681a097f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Fri, 20 Oct 2023 13:01:48 +0200 Subject: [PATCH] refac: `WebDAV.list_files` usage; translate doc --- api/ovdashboard_api/core/webdav.py | 14 +++++++------- api/ovdashboard_api/routers/v1/_common.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/api/ovdashboard_api/core/webdav.py b/api/ovdashboard_api/core/webdav.py index a907841..fdaed1d 100644 --- a/api/ovdashboard_api/core/webdav.py +++ b/api/ovdashboard_api/core/webdav.py @@ -35,7 +35,7 @@ class WebDAV: regex: re.Pattern[str] = re.compile(""), ) -> list[str]: """ - Liste aller Dateien im Ordner `directory`, die zur RegEx `regex` passen + List files in directory `directory` matching RegEx `regex` """ _logger.debug(f"list_files {directory!r}") @@ -49,9 +49,9 @@ class WebDAV: maxsize=SETTINGS.webdav.cache_size, skip_args=1, ) - async def file_exists(cls, path: str) -> bool: + async def exists(cls, path: str) -> bool: """ - `True`, wenn an Pfad `path` eine Datei existiert + `True` iff there is a WebDAV resource at `path` """ _logger.debug(f"file_exists {path!r}") @@ -67,7 +67,7 @@ class WebDAV: ) async def read_bytes(cls, path: str) -> bytes: """ - Datei aus Pfad `path` als bytes laden + Load WebDAV file from `path` as bytes """ _logger.debug(f"read_bytes {path!r}") @@ -79,7 +79,7 @@ class WebDAV: @classmethod async def read_str(cls, path: str, encoding="utf-8") -> str: """ - Datei aus Pfad `path` als string laden + Load WebDAV file from `path` as string """ _logger.debug(f"read_str {path!r}") @@ -88,7 +88,7 @@ class WebDAV: @classmethod async def write_bytes(cls, path: str, buffer: bytes) -> None: """ - Bytes `buffer` in Datei in Pfad `path` schreiben + Write bytes from `buffer` into WebDAV file at `path` """ _logger.debug(f"write_bytes {path!r}") @@ -106,7 +106,7 @@ class WebDAV: @classmethod async def write_str(cls, path: str, content: str, encoding="utf-8") -> None: """ - String `content` in Datei in Pfad `path` schreiben + Write string from `content` into WebDAV file at `path` """ _logger.debug(f"write_str {path!r}") diff --git a/api/ovdashboard_api/routers/v1/_common.py b/api/ovdashboard_api/routers/v1/_common.py index f96cb28..8e277cf 100644 --- a/api/ovdashboard_api/routers/v1/_common.py +++ b/api/ovdashboard_api/routers/v1/_common.py @@ -62,9 +62,9 @@ class FileNameLister: async def __call__(self) -> Iterator[str]: try: - file_names = await WebDAV.list_files(await self.remote_path) + file_names = await WebDAV.list_files(await self.remote_path, regex=self.re) - return (name for name in file_names if self.re.search(name)) + return iter(file_names) except RemoteResourceNotFound: _logger.error(