From ea1dc542a37d5b16292d15b16d99888f4334bbe6 Mon Sep 17 00:00:00 2001 From: profitroll Date: Tue, 3 Jan 2023 13:16:57 +0100 Subject: [PATCH] Improved docstrings --- modules/utils.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/utils.py b/modules/utils.py index bfdf21e..c90d473 100644 --- a/modules/utils.py +++ b/modules/utils.py @@ -193,6 +193,15 @@ def find_location(query: str) -> dict: raise PlaceNotFoundError(query) def create_tmp(bytedata: Union[bytes, bytearray], kind: Union[Literal["image", "video"], None]) -> str: + """Create temporary file to help uploading it + + ### Args: + * bytedata (`Union[bytes, bytearray]`): Some bytes to be written + * kind (`Union[Literal["image", "video"], None]`): Kind of upload. Will add `.jpg` or `.mp4` if needed + + ### Returns: + * `str`: Path to temporary file + """ filename = str(uuid1()) if kind == "image": filename += ".jpg" @@ -204,6 +213,15 @@ def create_tmp(bytedata: Union[bytes, bytearray], kind: Union[Literal["image", " return path.join("tmp", filename) async def download_tmp(app: Client, file_id: str) -> bytes: + """Download file by its ID and return its bytes + + ### Args: + * app (`Client`): App that will download the file + * file_id (`str`): File's unique id + + ### Returns: + * `bytes`: Bytes of downloaded file + """ filename = str(uuid1()) makedirs("tmp", exist_ok=True) await app.download_media(file_id, path.join("tmp", filename))