refac: WebDAV.list_files usage; translate doc

This commit is contained in:
Jörn-Michael Miehe 2023-10-20 13:01:48 +02:00
parent 17b9e274c1
commit 19c6772b88
2 changed files with 9 additions and 9 deletions

View file

@ -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}")

View file

@ -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(