From 7827d3a8b22e923b384ecc9cce581f74aa9975dd Mon Sep 17 00:00:00 2001 From: SlyAimer <2289782085@qq.com> Date: Tue, 4 Mar 2025 21:11:11 +0800 Subject: [PATCH] =?UTF-8?q?refactor(file=5Foperations):=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84=E5=A4=84=E7=90=86?= =?UTF-8?q?=E5=92=8C=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96=E6=96=B9=E5=BC=8F?= =?UTF-8?q?-=20=E5=B0=86=20Path()=20/=20=E7=94=A8=E6=B3=95=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E4=B8=BA=20os.path.join()=EF=BC=8C=E4=BB=A5=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E4=B8=8D=E5=90=8C=E6=93=8D=E4=BD=9C=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=20-=20=E4=BF=AE=E6=AD=A3=E6=96=87=E4=BB=B6=E6=89=93=E5=BC=80?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=EF=BC=8C=E4=BD=BF=E7=94=A8=20open(file,=20"r?= =?UTF-8?q?b")=20=E6=9B=BF=E4=BB=A3=20file.open("rb")=20-=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=A4=9A=E4=B8=AA=E6=96=87=E4=BB=B6=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E9=AB=98=E4=BB=A3=E7=A0=81=E7=9A=84=E5=8F=AF=E7=A7=BB?= =?UTF-8?q?=E6=A4=8D=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/clover_lightnovel/html_to_img.py | 4 ++-- src/clover_report/data_source.py | 4 ++-- src/clover_yuc_wiki/yuc_wiki.py | 4 ++-- src/configs/path_config.py | 24 ++++++++++++------------ 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/clover_lightnovel/html_to_img.py b/src/clover_lightnovel/html_to_img.py index fa891c4..c6217e5 100644 --- a/src/clover_lightnovel/html_to_img.py +++ b/src/clover_lightnovel/html_to_img.py @@ -23,9 +23,9 @@ async def save_img(data: bytes): async def get_ln_image(): now = datetime.now() - file = Path() / temp_path / f"{now.date()}轻小说.png" + file = os.path.join(temp_path , f"{now.date()}轻小说.png") if os.path.exists(file): - with file.open("rb") as image_file: + with open(file,"rb") as image_file: return image_file.read() await Wenku8.login() diff --git a/src/clover_report/data_source.py b/src/clover_report/data_source.py index 4033974..8234a5c 100644 --- a/src/clover_report/data_source.py +++ b/src/clover_report/data_source.py @@ -98,9 +98,9 @@ class Report: async def get_report_image(cls) -> bytes: """获取数据""" now = datetime.now() - file = Path() / temp_path / f"{now.date()}日报.png" + file = os.path.join(temp_path,f"{now.date()}日报.png") if os.path.exists(file): - with file.open("rb") as image_file: + with open(file,"rb") as image_file: return image_file.read() zhdata = ZhDate.from_datetime(now) result = await asyncio.gather( diff --git a/src/clover_yuc_wiki/yuc_wiki.py b/src/clover_yuc_wiki/yuc_wiki.py index 08666a7..3e26ea3 100644 --- a/src/clover_yuc_wiki/yuc_wiki.py +++ b/src/clover_yuc_wiki/yuc_wiki.py @@ -85,9 +85,9 @@ async def dispose_html(response): async def get_yuc_wiki_image(template_name,width,height): - file = Path() / yuc_wiki_path / f"{template_name}.jpeg" + file = os.path.join(yuc_wiki_path, f"{template_name}.jpeg") if os.path.exists(file): - with file.open("rb") as image_file: + with open(file,"rb") as image_file: return image_file.read() image_bytes = await template_to_pic( diff --git a/src/configs/path_config.py b/src/configs/path_config.py index 99f0865..366d334 100644 --- a/src/configs/path_config.py +++ b/src/configs/path_config.py @@ -1,41 +1,41 @@ import os from pathlib import Path -path = os.getcwd()+'/src/resources' +path = os.path.join(os.getcwd(), '/src/resources') # 塔罗牌图片路径 -image_local_qq_image_path = path+'/image/qq_image' +image_local_qq_image_path = os.path.join(path,'/image/qq_image') os.makedirs(image_local_qq_image_path, exist_ok=True) # 个人图片路径 -image_local_path= path+"/image/MaoYuNa" +image_local_path= os.path.join(path,"/image/MaoYuNa") os.makedirs(image_local_path, exist_ok=True) # 塔罗牌图片路径 -tarots_img_path = path+'/image/tarot/TarotImages/' +tarots_img_path = os.path.join(path,'/image/tarot/TarotImages/') os.makedirs(tarots_img_path, exist_ok=True) # 摸摸头图片路径 -rua_png = path+'/image/rua/' +rua_png = os.path.join(path,'/image/rua/') os.makedirs(rua_png, exist_ok=True) # 喜报、悲报图片路径 -good_bad = path+'/image/good_bad_news/' +good_bad = os.path.join(path,'/image/good_bad_news/') os.makedirs(good_bad, exist_ok=True) #谁说 生成图片路径 -who_say_path = path+'/image/who_say/' +who_say_path = os.path.join(path,'/image/who_say/') os.makedirs(who_say_path, exist_ok=True) #yuc_wiki 动漫wiki -yuc_wiki_path = path + '/image/yuc_wiki/' +yuc_wiki_path = os.path.join(path , '/image/yuc_wiki/') os.makedirs(yuc_wiki_path, exist_ok=True) # 字体路径 -font_path = path + '/font/' +font_path = os.path.join(path , '/font/') os.makedirs(font_path, exist_ok=True) # 临时数据路径 -temp_path = path + '/temp/' +temp_path = os.path.join(path , '/temp/') os.makedirs(temp_path, exist_ok=True) # 日志路径 -log_path = path+'/log/' +log_path = os.path.join(path,'/log/') os.makedirs(log_path, exist_ok=True) # 视频路径 -video_path = path+'/video/' +video_path = os.path.join(path,'/video/') os.makedirs(video_path, exist_ok=True)