Skip to content

Commit 9ab4de6

Browse files
authored
v2.0.9: 修复缓存bug,优化代码 (#69)
1 parent 65e1b01 commit 9ab4de6

File tree

4 files changed

+6
-12
lines changed

4 files changed

+6
-12
lines changed

src/jmcomic/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# 被依赖方 <--- 使用方
33
# config <--- entity <--- toolkit <--- client <--- option
44

5-
__version__ = '2.0.8'
5+
__version__ = '2.0.9'
66

77
from .api import *

src/jmcomic/jm_client_impl.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ def enable_cache(self, debug=False):
7777
def wrap_func_cache(func_name, cache_dict_name):
7878
import common
7979
if common.VERSION > '0.4.8':
80+
if hasattr(self, cache_dict_name):
81+
return
82+
8083
cache = common.cache
8184
cache_dict = {}
8285
cache_hit_msg = (f'【缓存命中】{cache_dict_name} ' + '→ [{}]') if debug is True else None
@@ -95,9 +98,6 @@ def wrap_func_cache(func_name, cache_dict_name):
9598
import functools
9699
cache = functools.cache
97100

98-
if hasattr(self, cache_dict_name):
99-
return
100-
101101
# 重载本对象的方法
102102
func = getattr(self, func_name)
103103
wrap_func = cache(func)

src/jmcomic/jm_config.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ def default_jm_debug(topic: str, msg: str):
66
def default_postman_constructor(session, **kwargs):
77
from common import Postmans
88

9-
kwargs.setdefault('impersonate', 'chrome110')
10-
kwargs.setdefault('headers', JmModuleConfig.headers())
11-
129
if session is True:
1310
return Postmans.new_session(**kwargs)
1411

@@ -101,6 +98,8 @@ def disable_jm_debug(cls):
10198

10299
@classmethod
103100
def new_postman(cls, session=False, **kwargs):
101+
kwargs.setdefault('impersonate', 'chrome110')
102+
kwargs.setdefault('headers', JmModuleConfig.headers())
104103
return cls.postman_constructor(session, **kwargs)
105104

106105
@classmethod

src/jmcomic/jm_toolkit.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ def parse_to_photo_id(cls, text) -> str:
6565
if (c0 == 'J' or c0 == 'j') and (c1 == 'M' or c1 == 'm'):
6666
# JM123456
6767
return text[2:]
68-
69-
elif text.isdigit():
70-
# 123456
71-
return str(text)
72-
7368
else:
7469
# https://xxx/photo/412038
7570
match = cls.pattern_jm_pa_id.search(text)

0 commit comments

Comments
 (0)