diff options
author | Lint Action <[email protected]> | 2021-08-26 02:45:06 +0000 |
---|---|---|
committer | Lint Action <[email protected]> | 2021-08-26 02:45:06 +0000 |
commit | b91bb2c0ccce4443c1cfe6b7de5ba33439ca6cf2 (patch) | |
tree | acda55ba0f417b0d992998cd254464cfb00777f7 /ATRI/utils | |
parent | b4667a5c838adb7a4d0a53eeee992e4784231895 (diff) | |
download | ATRI-b91bb2c0ccce4443c1cfe6b7de5ba33439ca6cf2.tar.gz ATRI-b91bb2c0ccce4443c1cfe6b7de5ba33439ca6cf2.tar.bz2 ATRI-b91bb2c0ccce4443c1cfe6b7de5ba33439ca6cf2.zip |
:rotating_light: 自动进行代码格式化
Diffstat (limited to 'ATRI/utils')
-rw-r--r-- | ATRI/utils/__init__.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/ATRI/utils/__init__.py b/ATRI/utils/__init__.py index d4298f5..68a69b6 100644 --- a/ATRI/utils/__init__.py +++ b/ATRI/utils/__init__.py @@ -37,6 +37,7 @@ class ListDealer: """ 对列表进行处理 """ + def __init__(self, lst: list, aim): self.lst = lst self.aim = aim @@ -58,6 +59,7 @@ class CoolqCodeChecker: """ 检查所传回的cq码是否存在被注入可能 """ + tenc_gchat_url: str = "gchat.qpic.cn" may_inject_keys: list = ["record", "video", "music", "xml", "json"] @@ -87,14 +89,14 @@ class FileDealer: """ 打开文件 """ + def __init__(self, path: Path, encoding: str = "utf-8"): self.path = path self.encoding = encoding async def write(self, path: Path, content): try: - async with aiofiles.open(path, "w", - encoding=self.encoding) as target: + async with aiofiles.open(path, "w", encoding=self.encoding) as target: await target.write(content) except Exception: raise Exception(f"Writing file({path}) failed!") @@ -127,11 +129,8 @@ class ImageDealer: """ 对图片进行压缩处理 """ - def __init__(self, - out_path, - kb: int = 300, - quality: int = 85, - k: float = 0.9): + + def __init__(self, out_path, kb: int = 300, quality: int = 85, k: float = 0.9): self.out_path = out_path self.kb = kb self.quality = quality @@ -146,8 +145,7 @@ class ImageDealer: while o_size > self.kb: img = Image.open(self.out_path) x, y = img.size - out = img.resize((int(x * self.k), int(y * self.k)), - Image.ANTIALIAS) + out = img.resize((int(x * self.k), int(y * self.k)), Image.ANTIALIAS) try: out.save(self.out_path, quality=self.quality) except Exception: |