mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-23 00:03:07 +00:00
dav_* naming
This commit is contained in:
parent
752c449831
commit
7fc8f8bbc5
2 changed files with 7 additions and 7 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue