From 7fc8f8bbc5e834dad5b3473a3338a7dd39478b6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Fri, 14 Oct 2022 22:15:20 +0000 Subject: [PATCH] dav_* naming --- api/advent22_api/dav_common.py | 8 ++++---- api/advent22_api/routers/days.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/advent22_api/dav_common.py b/api/advent22_api/dav_common.py index cb64a21..b01d898 100644 --- a/api/advent22_api/dav_common.py +++ b/api/advent22_api/dav_common.py @@ -13,16 +13,16 @@ _WEBDAV_CLIENT = WebDAVclient({ }) -async def list_files(regex: re.Pattern, path: str = "") -> list[str]: - ls = _WEBDAV_CLIENT.list(path) +async def dav_list_files(regex: re.Pattern, directory: str = "") -> list[str]: + ls = _WEBDAV_CLIENT.list(directory) return [ - path + f"{directory}/{path}" for path in ls if regex.search(path) ] -async def get_file(path: str) -> BytesIO: +async def dav_get_file(path: str) -> BytesIO: resource = _WEBDAV_CLIENT.resource(path) buffer = BytesIO() resource.write_to(buffer) diff --git a/api/advent22_api/routers/days.py b/api/advent22_api/routers/days.py index 52d186f..9c3c7cc 100644 --- a/api/advent22_api/routers/days.py +++ b/api/advent22_api/routers/days.py @@ -8,7 +8,7 @@ from fastapi import APIRouter, Depends from fastapi.responses import StreamingResponse from PIL import ImageDraw, ImageFont -from ..dav_common import get_file, list_files +from ..dav_common import dav_get_file, dav_list_files from ._image import AdventImage router = APIRouter(prefix="/days", tags=["days"]) @@ -75,9 +75,9 @@ async def load_image( # Bild laden rnd = random.Random(f"{loesungswort}{index}") - dat = rnd.choice(await list_files(_RE_IMAGE_FILE)) + dat = rnd.choice(await dav_list_files(_RE_IMAGE_FILE, "/images")) - img_buffer = await get_file(dat) + img_buffer = await dav_get_file(dat) return await AdventImage.load_standard(img_buffer)