diff options
Diffstat (limited to 'kvmd/aiotools.py')
-rw-r--r-- | kvmd/aiotools.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/kvmd/aiotools.py b/kvmd/aiotools.py index a5a28fde..c87e8268 100644 --- a/kvmd/aiotools.py +++ b/kvmd/aiotools.py @@ -26,7 +26,6 @@ import asyncio import ssl import functools import types - import typing from typing import Callable @@ -35,10 +34,18 @@ from typing import Coroutine from typing import TypeVar from typing import Any +import aiofiles + from .logging import get_logger # ===== +async def read_file(path: str) -> str: + async with aiofiles.open(path) as file: + return (await file.read()) + + +# ===== def run(coro: Coroutine, final: (Coroutine | None)=None) -> None: # https://github.com/aio-libs/aiohttp/blob/a1d4dac1d/aiohttp/web.py#L515 |