correct text file decoding
This commit is contained in:
parent
4ea2b37362
commit
b93f95020d
2 changed files with 10 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
|||
import re
|
||||
from io import BytesIO
|
||||
from io import BytesIO, TextIOWrapper
|
||||
from typing import TextIO
|
||||
|
||||
from webdav3.client import Client as WebDAVclient
|
||||
|
||||
|
@ -29,3 +30,8 @@ async def dav_get_file(path: str) -> BytesIO:
|
|||
buffer.seek(0)
|
||||
|
||||
return buffer
|
||||
|
||||
|
||||
async def dav_get_textfile(path: str, encoding="utf-8") -> TextIO:
|
||||
buffer = await dav_get_file(path)
|
||||
return TextIOWrapper(buffer, encoding=encoding)
|
||||
|
|
|
@ -2,12 +2,12 @@ import itertools
|
|||
import random
|
||||
from typing import Any, Sequence
|
||||
|
||||
from ..dav_common import dav_get_file
|
||||
from ..dav_common import dav_get_textfile
|
||||
|
||||
|
||||
async def get_loesungswort() -> str:
|
||||
fp = await dav_get_file("loesungswort.txt")
|
||||
return fp.read().decode("utf8").strip()
|
||||
fp = await dav_get_textfile("loesungswort.txt")
|
||||
return fp.read().strip()
|
||||
|
||||
|
||||
async def get_rnd(bonus_salt: Any = "") -> random.Random:
|
||||
|
|
Loading…
Reference in a new issue