diff --git a/api/advent22_api/dav_common.py b/api/advent22_api/dav_common.py index 264182a..6f6e3c2 100644 --- a/api/advent22_api/dav_common.py +++ b/api/advent22_api/dav_common.py @@ -17,7 +17,7 @@ _WEBDAV_CLIENT = WebDAVclient( @AsyncTTL(time_to_live=SETTINGS.cache_ttl) -async def dav_list_files(regex: re.Pattern, directory: str = "") -> list[str]: +async def dav_list_files(regex: re.Pattern[str], directory: str = "") -> list[str]: ls = _WEBDAV_CLIENT.list(directory) return [f"{directory}/{path}" for path in ls if regex.search(path)] diff --git a/api/advent22_api/routers/_misc.py b/api/advent22_api/routers/_misc.py index ec44dd2..899bf88 100644 --- a/api/advent22_api/routers/_misc.py +++ b/api/advent22_api/routers/_misc.py @@ -51,17 +51,15 @@ async def get_letter( return (await shuffle(cfg.puzzle.solution))[index] -_RE_IMAGE_FILE = re.compile( - r"\.(gif|jpe?g|tiff?|png|bmp)$", - flags=re.IGNORECASE, -) - - async def list_images_auto() -> list[str]: """ Finde alle Bilder im "automatisch"-Verzeichnis """ - ls = await dav_list_files(_RE_IMAGE_FILE, "/images_auto") + + ls = await dav_list_files( + re.compile(r"\.(gif|jpe?g|tiff?|png|bmp)$", flags=re.IGNORECASE), + "/images_auto", + ) ls = await set_length(ls, 24) return await shuffle(ls)