basic readability
This commit is contained in:
parent
a5751c973a
commit
5cf0846c68
2 changed files with 6 additions and 8 deletions
|
@ -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)]
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue