From c5895d2ff050621e49392bb01a519212baced90f Mon Sep 17 00:00:00 2001 From: hect0x7 <93357912+hect0x7@users.noreply.github.com> Date: Wed, 15 Nov 2023 22:36:10 +0800 Subject: [PATCH] fix typo, format code --- src/jmcomic/cl.py | 10 +++++----- src/jmcomic/jm_client_impl.py | 14 +++++++------- src/jmcomic/jm_client_interface.py | 1 - src/jmcomic/jm_downloader.py | 28 ++++++++++++++-------------- src/jmcomic/jm_option.py | 6 +++--- src/jmcomic/jm_plugin.py | 2 +- tests/test_jmcomic/test_jm_custom.py | 2 +- 7 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/jmcomic/cl.py b/src/jmcomic/cl.py index 0d9eb057..a3e2add3 100644 --- a/src/jmcomic/cl.py +++ b/src/jmcomic/cl.py @@ -79,11 +79,11 @@ def main(self): self.parse_arg() from .api import jm_log jm_log('command_line', - f'start downloading...\n' - f'- using option: [{self.option_path or "default"}]\n' - f'to be downloaded: \n' - f'- album: {self.album_id_list}\n' - f'- photo: {self.photo_id_list}') + f'start downloading...\n' + f'- using option: [{self.option_path or "default"}]\n' + f'to be downloaded: \n' + f'- album: {self.album_id_list}\n' + f'- photo: {self.photo_id_list}') from .api import create_option, JmOption if self.option_path is not None: diff --git a/src/jmcomic/jm_client_impl.py b/src/jmcomic/jm_client_impl.py index 87507974..b90541b9 100644 --- a/src/jmcomic/jm_client_impl.py +++ b/src/jmcomic/jm_client_impl.py @@ -86,12 +86,12 @@ def request_with_retry(self, if domain_index != 0 or retry_count != 0: jm_log(f'req.retry', - ', '.join([ - f'次数: [{retry_count}/{self.retry_times}]', - f'域名: [{domain_index} of {self.domain_list}]', - f'路径: [{url}]', - f'参数: [{kwargs if "login" not in url else "#login_form#"}]' - ]) + ', '.join([ + f'次数: [{retry_count}/{self.retry_times}]', + f'域名: [{domain_index} of {self.domain_list}]', + f'路径: [{url}]', + f'参数: [{kwargs if "login" not in url else "#login_form#"}]' + ]) ) try: @@ -386,7 +386,7 @@ def album_comment(self, data['forum_subject'] = 1 jm_log('album.comment', - f'{video_id}: [{comment}]' + + f'{video_id}: [{comment}]' + (f' to ({comment_id})' if comment_id is not None else '') ) diff --git a/src/jmcomic/jm_client_interface.py b/src/jmcomic/jm_client_interface.py index 316ba03c..9cbf05d0 100644 --- a/src/jmcomic/jm_client_interface.py +++ b/src/jmcomic/jm_client_interface.py @@ -145,7 +145,6 @@ def json(self, **kwargs) -> Dict: """ - class JmDetailClient: def get_album_detail(self, album_id) -> JmAlbumDetail: diff --git a/src/jmcomic/jm_downloader.py b/src/jmcomic/jm_downloader.py index de4ff9dc..c50f75f7 100644 --- a/src/jmcomic/jm_downloader.py +++ b/src/jmcomic/jm_downloader.py @@ -6,12 +6,12 @@ class DownloadCallback: def before_album(self, album: JmAlbumDetail): jm_log('album.before', - f'本子获取成功: [{album.id}], ' - f'作者: [{album.author}], ' - f'章节数: [{len(album)}], ' - f'总页数: [{album.page_count}], ' - f'标题: [{album.name}], ' - f'关键词: [{album.tags}]' + f'本子获取成功: [{album.id}], ' + f'作者: [{album.author}], ' + f'章节数: [{len(album)}], ' + f'总页数: [{album.page_count}], ' + f'标题: [{album.name}], ' + f'关键词: [{album.tags}]' ) def after_album(self, album: JmAlbumDetail): @@ -19,28 +19,28 @@ def after_album(self, album: JmAlbumDetail): def before_photo(self, photo: JmPhotoDetail): jm_log('photo.before', - f'开始下载章节: {photo.id} ({photo.album_id}[{photo.index}/{len(photo.from_album)}]), ' - f'标题: [{photo.name}], ' - f'图片数为[{len(photo)}]' + f'开始下载章节: {photo.id} ({photo.album_id}[{photo.index}/{len(photo.from_album)}]), ' + f'标题: [{photo.name}], ' + f'图片数为[{len(photo)}]' ) def after_photo(self, photo: JmPhotoDetail): jm_log('photo.after', - f'章节下载完成: [{photo.id}] ({photo.album_id}[{photo.index}/{len(photo.from_album)}])') + f'章节下载完成: [{photo.id}] ({photo.album_id}[{photo.index}/{len(photo.from_album)}])') def before_image(self, image: JmImageDetail, img_save_path): if image.is_exists: jm_log('image.before', - f'图片已存在: {image.tag} ← [{img_save_path}]' + f'图片已存在: {image.tag} ← [{img_save_path}]' ) else: jm_log('image.before', - f'图片准备下载: {image.tag}, [{image.img_url}] → [{img_save_path}]' + f'图片准备下载: {image.tag}, [{image.img_url}] → [{img_save_path}]' ) def after_image(self, image: JmImageDetail, img_save_path): jm_log('image.after', - f'图片下载完成: {image.tag}, [{image.img_url}] → [{img_save_path}]') + f'图片下载完成: {image.tag}, [{image.img_url}] → [{img_save_path}]') class JmDownloader(DownloadCallback): @@ -196,5 +196,5 @@ def __enter__(self): def __exit__(self, exc_type, exc_val, exc_tb): if exc_type is not None: jm_log('dler.exception', - f'{self.__class__.__name__} Exit with exception: {exc_type, exc_val}' + f'{self.__class__.__name__} Exit with exception: {exc_type, exc_val}' ) diff --git a/src/jmcomic/jm_option.py b/src/jmcomic/jm_option.py index 6c270757..21a0dd8c 100644 --- a/src/jmcomic/jm_option.py +++ b/src/jmcomic/jm_option.py @@ -79,7 +79,7 @@ def __init__(self, rule: str, base_dir=None): self.rule_dsl = rule self.solver_list = self.get_role_solver_list(rule, base_dir) - def deside_image_save_dir(self, + def decide_image_save_dir(self, album: JmAlbumDetail, photo: JmPhotoDetail, ) -> str: @@ -205,7 +205,7 @@ def decide_photo_batch_count(self, album: JmAlbumDetail): def decide_image_save_dir(self, photo) -> str: # 使用 self.dir_rule 决定 save_dir - save_dir = self.dir_rule.deside_image_save_dir( + save_dir = self.dir_rule.decide_image_save_dir( photo.from_album, photo ) @@ -566,7 +566,7 @@ def handle_plugin_valid_exception(self, e, pinfo: dict, kwargs: dict, plugin): if mode == 'log': # log jm_log('plugin.validation', - f'插件 [{e.plugin.plugin_key}] 参数校验异常:{e.msg}' + f'插件 [{e.plugin.plugin_key}] 参数校验异常:{e.msg}' ) return diff --git a/src/jmcomic/jm_plugin.py b/src/jmcomic/jm_plugin.py index d6a7cab7..b57553a4 100644 --- a/src/jmcomic/jm_plugin.py +++ b/src/jmcomic/jm_plugin.py @@ -416,7 +416,7 @@ def invoke(self, def apply_filter_then_decide_cache(image: JmImageDetail): if image.img_file_suffix not in allowed_suffix_set: self.log(f'跳过下载图片: {image.tag},' - f'因为其后缀\'{image.img_file_suffix}\'不在允许的后缀集合{allowed_suffix_set}内') + f'因为其后缀\'{image.img_file_suffix}\'不在允许的后缀集合{allowed_suffix_set}内') # hook is_exists True to skip download image.is_exists = True return True diff --git a/tests/test_jmcomic/test_jm_custom.py b/tests/test_jmcomic/test_jm_custom.py index 9e6015e1..d1946dc9 100644 --- a/tests/test_jmcomic/test_jm_custom.py +++ b/tests/test_jmcomic/test_jm_custom.py @@ -27,7 +27,7 @@ def pname(self): base_dir: str = workspace() dir_rule = DirRule('Bd_Aaname_Ppname', base_dir) # noinspection PyTypeChecker - save_dir = dir_rule.deside_image_save_dir( + save_dir = dir_rule.decide_image_save_dir( MyAlbum('1', '0', '0', [], *['0'] * 10), MyPhoto('2', *['0'] * 7) )