basic readability

This commit is contained in:
Jörn-Michael Miehe 2023-09-08 01:19:15 +00:00
parent a5751c973a
commit 5cf0846c68
2 changed files with 6 additions and 8 deletions

View file

@ -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)]

View file

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