diff options
author | Maxim Devaev <[email protected]> | 2024-09-18 04:37:43 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2024-09-18 04:37:43 +0300 |
commit | 7a53f1445619fc471c2823e7081de8b6039b938e (patch) | |
tree | 961dd0072cc976504fe4570743d801c79512e9a6 /kvmd/htclient.py | |
parent | 45270a09d7b5076bac96887a1e36d752882e3adf (diff) |
refactoring
Diffstat (limited to 'kvmd/htclient.py')
-rw-r--r-- | kvmd/htclient.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/kvmd/htclient.py b/kvmd/htclient.py index 9d9ae82c..5978b189 100644 --- a/kvmd/htclient.py +++ b/kvmd/htclient.py @@ -36,27 +36,27 @@ def make_user_agent(app: str) -> str: return f"{app}/{__version__}" -def raise_not_200(response: aiohttp.ClientResponse) -> None: - if response.status != 200: - assert response.reason is not None - response.release() +def raise_not_200(resp: aiohttp.ClientResponse) -> None: + if resp.status != 200: + assert resp.reason is not None + resp.release() raise aiohttp.ClientResponseError( - response.request_info, - response.history, - status=response.status, - message=response.reason, - headers=response.headers, + resp.request_info, + resp.history, + status=resp.status, + message=resp.reason, + headers=resp.headers, ) -def get_filename(response: aiohttp.ClientResponse) -> str: +def get_filename(resp: aiohttp.ClientResponse) -> str: try: - disp = response.headers["Content-Disposition"] + disp = resp.headers["Content-Disposition"] parsed = aiohttp.multipart.parse_content_disposition(disp) return str(parsed[1]["filename"]) except Exception: try: - return os.path.basename(response.url.path) + return os.path.basename(resp.url.path) except Exception: raise aiohttp.ClientError("Can't determine filename") @@ -79,6 +79,6 @@ async def download( ), } async with aiohttp.ClientSession(**kwargs) as session: - async with session.get(url, verify_ssl=verify) as response: # type: ignore - raise_not_200(response) - yield response + async with session.get(url, verify_ssl=verify) as resp: # type: ignore + raise_not_200(resp) + yield resp |