From 21ad51ffbf6dc5a372c021ca9821e98808fbb4d5 Mon Sep 17 00:00:00 2001 From: zhayujie Date: Mon, 27 Nov 2023 14:24:26 +0800 Subject: [PATCH] fix: remove repeat util --- channel/feishu/feishu_channel.py | 4 ++-- channel/feishu/feishu_message.py | 4 ++-- utils/file_util.py | 8 -------- 3 files changed, 4 insertions(+), 12 deletions(-) delete mode 100644 utils/file_util.py diff --git a/channel/feishu/feishu_channel.py b/channel/feishu/feishu_channel.py index 5e7e4fc..85e40d7 100644 --- a/channel/feishu/feishu_channel.py +++ b/channel/feishu/feishu_channel.py @@ -19,7 +19,7 @@ from config import conf from common.expired_dict import ExpiredDict from bridge.context import ContextType from channel.chat_channel import ChatChannel, check_prefix -from utils import file_util +from common import utils import json import os @@ -118,7 +118,7 @@ class FeiShuChanel(ChatChannel): def _upload_image_url(self, img_url, access_token): logger.debug(f"[WX] start download image, img_url={img_url}") response = requests.get(img_url) - suffix = file_util.get_path_suffix(img_url) + suffix = utils.get_path_suffix(img_url) temp_name = str(uuid.uuid4()) + "." + suffix if response.status_code == 200: # 将图片内容保存为临时文件 diff --git a/channel/feishu/feishu_message.py b/channel/feishu/feishu_message.py index fa6057e..73285f2 100644 --- a/channel/feishu/feishu_message.py +++ b/channel/feishu/feishu_message.py @@ -4,7 +4,7 @@ import json import requests from common.log import logger from common.tmp_dir import TmpDir -from utils import file_util +from common import utils class FeishuMessage(ChatMessage): @@ -28,7 +28,7 @@ class FeishuMessage(ChatMessage): file_key = content.get("file_key") file_name = content.get("file_name") - self.content = TmpDir().path() + file_key + "." + file_util.get_path_suffix(file_name) + self.content = TmpDir().path() + file_key + "." + utils.get_path_suffix(file_name) def _download_file(): # 如果响应状态码是200,则将响应内容写入本地文件 diff --git a/utils/file_util.py b/utils/file_util.py deleted file mode 100644 index 6db659c..0000000 --- a/utils/file_util.py +++ /dev/null @@ -1,8 +0,0 @@ -from urllib.parse import urlparse -import os - - -# 获取url后缀 -def get_path_suffix(path): - path = urlparse(path).path - return os.path.splitext(path)[-1].lstrip('.')