From 684754af577e0646d73ab3cd1b80fcf03823ef83 Mon Sep 17 00:00:00 2001 From: hect0x7 <93357912+hect0x7@users.noreply.github.com> Date: Wed, 17 Jan 2024 00:57:05 +0800 Subject: [PATCH] =?UTF-8?q?v2.5.2:=20=E5=85=BC=E5=AE=B9v2.5.1=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E7=9A=84=E5=BC=82=E5=B8=B8hook=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=88v2.5.1=E4=BC=9A=E4=BD=BF=E5=BE=97=E6=97=A7=E7=9A=84Git?= =?UTF-8?q?Hub=20Actions=E4=B8=8B=E8=BD=BD=E8=84=9A=E6=9C=AC=E6=8A=A5?= =?UTF-8?q?=E9=94=99=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmcomic/__init__.py | 2 +- src/jmcomic/jm_exception.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/jmcomic/__init__.py b/src/jmcomic/__init__.py index 371c586..350706f 100644 --- a/src/jmcomic/__init__.py +++ b/src/jmcomic/__init__.py @@ -2,7 +2,7 @@ # 被依赖方 <--- 使用方 # config <--- entity <--- toolkit <--- client <--- option <--- downloader -__version__ = '2.5.1' +__version__ = '2.5.2' from .api import * from .jm_plugin import * diff --git a/src/jmcomic/jm_exception.py b/src/jmcomic/jm_exception.py index c2f7677..a75ab5e 100644 --- a/src/jmcomic/jm_exception.py +++ b/src/jmcomic/jm_exception.py @@ -65,6 +65,13 @@ class ExceptionTool: CONTEXT_KEY_RE_PATTERN = 'pattern' CONTEXT_KEY_MISSING_JM_ID = 'missing_jm_id' + # 兼容旧版本 + + EXTRA_KEY_RESP = 'resp' + EXTRA_KEY_HTML = 'html' + EXTRA_KEY_RE_PATTERN = 'pattern' + EXTRA_KEY_MISSING_JM_ID = 'missing_jm_id' + @classmethod def raises(cls, msg: str, @@ -156,3 +163,14 @@ class ExceptionTool: return cls.raises(msg) + + @classmethod + def replace_old_exception_executor(cls, raises: Callable[[Callable, str, dict], None]): + old = cls.raises + + def new(msg, context=None, _etype=None): + if context is None: + context = {} + raises(old, msg, context) + + cls.raises = new