From dc793e5d8d2c2ea2d48a51f6b04c1518dd44c200 Mon Sep 17 00:00:00 2001 From: Kyomotoi <1172294279@qq.com> Date: Sun, 31 May 2020 13:01:26 +0800 Subject: =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=83=A8=E5=88=86=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E4=BD=9C=E5=93=81=EF=BC=8C=E6=96=B0=E5=A2=9E=E7=96=AB=E6=83=85?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AyaBot/plugins/aio/requests.py | 71 ------------------------------------------ 1 file changed, 71 deletions(-) delete mode 100644 AyaBot/plugins/aio/requests.py (limited to 'AyaBot/plugins/aio/requests.py') diff --git a/AyaBot/plugins/aio/requests.py b/AyaBot/plugins/aio/requests.py deleted file mode 100644 index 4f7b9d3..0000000 --- a/AyaBot/plugins/aio/requests.py +++ /dev/null @@ -1,71 +0,0 @@ -from typing import Optional, Any - -import requests -from requests import * - -from . import run_sync_func - - -class AsyncResponse: - def __init__(self, response: requests.Response): - self.raw_response = response - - @property - def ok(self) -> bool: - return self.raw_response.ok - - def __repr__(self): - return '' % self.raw_response.status_code - - def __bool__(self): - return self.ok - - @property - async def content(self) -> Optional[bytes]: - return await run_sync_func(lambda: self.raw_response.content) - - @property - async def text(self) -> str: - return await run_sync_func(lambda: self.raw_response.text) - - async def json(self, **kwargs) -> Any: - return await run_sync_func(self.raw_response.json, **kwargs) - - -async def request(method, url, **kwargs) -> AsyncResponse: - return AsyncResponse(await run_sync_func(requests.request, - method=method, url=url, **kwargs)) - - -async def get(url, params=None, **kwargs) -> AsyncResponse: - return AsyncResponse( - await run_sync_func(requests.get, url=url, params=params, **kwargs)) - - -async def options(url, **kwargs) -> AsyncResponse: - return AsyncResponse( - await run_sync_func(requests.options, url=url, **kwargs)) - - -async def head(url, **kwargs) -> AsyncResponse: - return AsyncResponse(await run_sync_func(requests.head, url=url, **kwargs)) - - -async def post(url, data=None, json=None, **kwargs) -> AsyncResponse: - return AsyncResponse(await run_sync_func(requests.post, url=url, - data=data, json=json, **kwargs)) - - -async def put(url, data=None, **kwargs) -> AsyncResponse: - return AsyncResponse( - await run_sync_func(requests.put, url=url, data=data, **kwargs)) - - -async def patch(url, data=None, **kwargs) -> AsyncResponse: - return AsyncResponse( - await run_sync_func(requests.patch, url=url, data=data, **kwargs)) - - -async def delete(url, **kwargs) -> AsyncResponse: - return AsyncResponse( - await run_sync_func(requests.delete, url=url, **kwargs)) -- cgit v1.2.3