Improved docstrings
This commit is contained in:
parent
6aa8128fc6
commit
ea1dc542a3
@ -193,6 +193,15 @@ def find_location(query: str) -> dict:
|
|||||||
raise PlaceNotFoundError(query)
|
raise PlaceNotFoundError(query)
|
||||||
|
|
||||||
def create_tmp(bytedata: Union[bytes, bytearray], kind: Union[Literal["image", "video"], None]) -> str:
|
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())
|
filename = str(uuid1())
|
||||||
if kind == "image":
|
if kind == "image":
|
||||||
filename += ".jpg"
|
filename += ".jpg"
|
||||||
@ -204,6 +213,15 @@ def create_tmp(bytedata: Union[bytes, bytearray], kind: Union[Literal["image", "
|
|||||||
return path.join("tmp", filename)
|
return path.join("tmp", filename)
|
||||||
|
|
||||||
async def download_tmp(app: Client, file_id: str) -> bytes:
|
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())
|
filename = str(uuid1())
|
||||||
makedirs("tmp", exist_ok=True)
|
makedirs("tmp", exist_ok=True)
|
||||||
await app.download_media(file_id, path.join("tmp", filename))
|
await app.download_media(file_id, path.join("tmp", filename))
|
||||||
|
Reference in New Issue
Block a user