- Notifications
You must be signed in to change notification settings - Fork9.7k
v2.6.10: 文件夹名称支持繁简转换,dir_rule增加normalize_zh配置#486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…dirs (use JmcomicText.to_zh_cn)
…igurable zh conversion; add JmcomicText.to_zh
coderabbitaibot commentedOct 27, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
WalkthroughAdds an optional dir_rule setting Changes
Sequence Diagram(s)sequenceDiagram participant User as User Config participant Config as JmModuleConfig participant DirRule as DirRule participant Text as JmcomicText User->>Config: load options (may include dir_rule.normalize_zh) Config->>DirRule: initialize(rule, base_dir, normalize_zh) DirRule->>DirRule: parse path components Note over DirRule,Text: For non-base-dir components, optionally normalize Chinese text DirRule->>Text: to_zh(component, normalize_zh) alt conversion succeeds Text-->>DirRule: converted component else conversion unavailable or fails Text-->>DirRule: original component (fallback) end DirRule->>DirRule: apply Windows name fixes (fix_windir_name) DirRule-->>User: final pathEstimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used🧬 Code graph analysis (2)src/jmcomic/jm_option.py (1)
src/jmcomic/jm_toolkit.py (1)
🪛 Ruff (0.14.1)src/jmcomic/jm_option.py67-67: Docstring contains ambiguous (RUF002) 69-69: (F405) 98-98: (F405) 99-99: (F405) src/jmcomic/jm_toolkit.py332-332: Comment contains ambiguous (RUF003) 341-341: Docstring contains ambiguous (RUF002) 341-341: Docstring contains ambiguous (RUF002) 341-341: Docstring contains ambiguous (RUF002) 341-341: Docstring contains ambiguous (RUF002) 341-341: Docstring contains ambiguous (RUF002) 342-342: Docstring contains ambiguous (RUF002) 342-342: Docstring contains ambiguous (RUF002) 342-342: Docstring contains ambiguous (RUF002) 353-353: Local variable Remove assignment to unused variable (F841) 354-354: (F405) 354-354: String contains ambiguous (RUF001) 354-354: String contains ambiguous (RUF001) 356-356: Do not catch blind exception: (BLE001) 357-357: Comment contains ambiguous (RUF003) 358-358: (F405) 🔇 Additional comments (6)
Thanks for usingCodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/jmcomic/jm_option.py (1)
98-109:Simplify defensive coding and narrow exception handling.The
getattr(self, 'normalize_zh', None)pattern appears redundant since__init__already setsself.normalize_zhwith a default value. This defensive pattern is only necessary if you need to support legacyDirRuleinstances created before this change. If backward compatibility with pickled/cached instances is not required, simplify totarget = self.normalize_zh.Additionally, the bare
except Exceptionon line 106 suppresses all errors, making debugging difficult if issues arise.If backward compatibility with old instances is not needed:
- # 根据配置 normalize_zh 进行繁简体统一或跳过- try:- target = getattr(self, 'normalize_zh', None)- if target is None:- # 默认为不转换- conv_path = str(path)- else:- conv_path = JmcomicText.to_zh(str(path), target)- except Exception:- conv_path = str(path)-- path = fix_windir_name(conv_path).strip()+ # 根据配置 normalize_zh 进行繁简体统一或跳过+ conv_path = JmcomicText.to_zh(str(path), self.normalize_zh)+ path = fix_windir_name(conv_path).strip()Note:
JmcomicText.to_zhalready handlesNonetargets and exceptions internally, so the defensive code here is redundant.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/jmcomic/jm_config.py(1 hunks)src/jmcomic/jm_option.py(5 hunks)src/jmcomic/jm_toolkit.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/jmcomic/jm_option.py (1)
src/jmcomic/jm_toolkit.py (2)
parse_to_abspath(239-240)to_zh(336-359)
🪛 Ruff (0.14.1)
src/jmcomic/jm_option.py
68-68: Docstring contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF002)
106-106: Do not catch blind exception:Exception
(BLE001)
109-109:fix_windir_name may be undefined, or defined from star imports
(F405)
src/jmcomic/jm_toolkit.py
332-332: Comment contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF003)
341-341: Docstring contains ambiguous( (FULLWIDTH LEFT PARENTHESIS). Did you mean( (LEFT PARENTHESIS)?
(RUF002)
341-341: Docstring contains ambiguous) (FULLWIDTH RIGHT PARENTHESIS). Did you mean) (RIGHT PARENTHESIS)?
(RUF002)
341-341: Docstring contains ambiguous( (FULLWIDTH LEFT PARENTHESIS). Did you mean( (LEFT PARENTHESIS)?
(RUF002)
341-341: Docstring contains ambiguous) (FULLWIDTH RIGHT PARENTHESIS). Did you mean) (RIGHT PARENTHESIS)?
(RUF002)
341-341: Docstring contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF002)
342-342: Docstring contains ambiguous( (FULLWIDTH LEFT PARENTHESIS). Did you mean( (LEFT PARENTHESIS)?
(RUF002)
342-342: Docstring contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF002)
342-342: Docstring contains ambiguous) (FULLWIDTH RIGHT PARENTHESIS). Did you mean) (RIGHT PARENTHESIS)?
(RUF002)
357-357: Do not catch blind exception:Exception
(BLE001)
358-358: Comment contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF003)
🔇 Additional comments (6)
src/jmcomic/jm_option.py (3)
64-74:LGTM with minor style note.The
normalize_zhparameter is well-documented and properly stored. The default value'zh-cn'aligns with the configuration injm_config.py.Note: Static analysis flagged the full-width comma (,) in the docstring at line 68. This is acceptable for Chinese documentation, though you may want to standardize on half-width punctuation for consistency with Python conventions.
217-229:LGTM!The
copy_optionmethod correctly propagates thenormalize_zhsetting when creating a copy of the option.
341-353:LGTM!The
deconstructmethod correctly includesnormalize_zhto ensure the setting is persisted when saving options to a file.src/jmcomic/jm_toolkit.py (2)
330-333:LGTM!Good refactoring to delegate to the new generic
to_zhmethod while preserving the existingto_zh_cnAPI for backward compatibility.
335-359: Based on my verification, I found that:
zhconv dependency status: zhconv is in
requirements-dev.txt(development-only) and is NOT in the maininstall_requiresordependenciessections of setup.py/pyproject.toml. This is intentional design—zhconv is already treated as an optional dependency.Exception handling appropriateness: For an optional dependency, the broad
except Exceptionwith silent fallback to the original string is a reasonable and safe pattern. The method correctly handles both missing library and conversion errors by returning the original string.jm_log existence: The function exists and is used throughout the codebase for logging, confirming the suggested improvement is feasible.
The implementation already follows good defensive patterns for optional dependencies. The current code safely handles the case when zhconv is unavailable.
No actionable issues found—current implementation appropriately handles zhconv as optional.
The
to_zhmethod correctly manages zhconv as an optional dependency. While zhconv is listed inrequirements-dev.txt, it's appropriately excluded from the main dependency list in setup.py/pyproject.toml, meaning users who don't need Chinese text conversion normalization won't be forced to install it. The defensive exception handling with silent fallback is acceptable for this optional feature—users get the original string if the library isn't available or conversion fails.The implementation is sound. No changes are required.
src/jmcomic/jm_config.py (1)
414-414:Verify backward compatibility claim - inconclusive without git history.The PR claims "default behavior remains unchanged," but verification is inconclusive:
DirRule.__init__has parameter defaultnormalize_zh='zh-cn'(line 64, jm_option.py)- Code defensively checks
if normalize_zh is Noneto apply "no conversion" (lines 100-102)- Line 414 now explicitly sets
'normalize_zh': 'zh-cn'inDEFAULT_OPTION_DICT- No git history, tests, or changelog available to confirm previous state
The key question: Was
normalize_zhpreviouslyabsent fromDEFAULT_OPTION_DICT(relying on parameter default 'zh-cn'), or was it explicitly set toNone/'none'(enabling no conversion by default)?Manually verify the previous version of this configuration dictionary to confirm whether this change affects existing behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/jmcomic/jm_option.py (1)
64-69:Consider replacing fullwidth punctuation in docstring.The docstring contains fullwidth commas and parentheses which Ruff flags as potentially ambiguous. For consistency with Python conventions, consider using ASCII punctuation.
Apply this diff to use ASCII punctuation:
- :param normalize_zh: 'zh-cn'|'zh-tw'| or None. 控制是否以及如何进行繁简体归一化,默认 None+ :param normalize_zh: 'zh-cn'|'zh-tw'| or None. 控制是否以及如何进行繁简体归一化, 默认 NoneBased on static analysis.
src/jmcomic/jm_toolkit.py (2)
331-333:LGTM!The refactoring of
to_zh_cnto delegate to the new genericto_zhmethod maintains backward compatibility while reducing code duplication.Optionally, replace the fullwidth comma in the comment with ASCII for consistency:
- # 兼容旧接口,默认转换为简体+ # 兼容旧接口, 默认转换为简体Based on static analysis.
337-343:Consider replacing fullwidth punctuation in docstring.The docstring contains fullwidth parentheses and commas which Ruff flags as potentially ambiguous. For consistency with Python conventions, consider using ASCII punctuation.
Apply this diff to use ASCII punctuation:
- :param target: 目标编码: 'zh-cn'(简体), 'zh-tw'(繁体),或 None/'none' 表示不转换- :return: 转换后的字符串(若转换失败或未安装 zhconv,返回原始字符串)+ :param target: 目标编码: 'zh-cn'(简体), 'zh-tw'(繁体), 或 None/'none' 表示不转换+ :return: 转换后的字符串(若转换失败或未安装 zhconv, 返回原始字符串)Based on static analysis.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
assets/option/option_test_api.yml(1 hunks)src/jmcomic/jm_config.py(1 hunks)src/jmcomic/jm_option.py(5 hunks)src/jmcomic/jm_toolkit.py(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/jmcomic/jm_config.py
🧰 Additional context used
🧬 Code graph analysis (2)
src/jmcomic/jm_option.py (1)
src/jmcomic/jm_toolkit.py (2)
parse_to_abspath(239-240)to_zh(336-356)
src/jmcomic/jm_toolkit.py (1)
src/jmcomic/jm_config.py (1)
jm_log(383-385)
🪛 Ruff (0.14.1)
src/jmcomic/jm_option.py
68-68: Docstring contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF002)
100-100:fix_windir_name may be undefined, or defined from star imports
(F405)
src/jmcomic/jm_toolkit.py
332-332: Comment contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF003)
341-341: Docstring contains ambiguous( (FULLWIDTH LEFT PARENTHESIS). Did you mean( (LEFT PARENTHESIS)?
(RUF002)
341-341: Docstring contains ambiguous) (FULLWIDTH RIGHT PARENTHESIS). Did you mean) (RIGHT PARENTHESIS)?
(RUF002)
341-341: Docstring contains ambiguous( (FULLWIDTH LEFT PARENTHESIS). Did you mean( (LEFT PARENTHESIS)?
(RUF002)
341-341: Docstring contains ambiguous) (FULLWIDTH RIGHT PARENTHESIS). Did you mean) (RIGHT PARENTHESIS)?
(RUF002)
341-341: Docstring contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF002)
342-342: Docstring contains ambiguous( (FULLWIDTH LEFT PARENTHESIS). Did you mean( (LEFT PARENTHESIS)?
(RUF002)
342-342: Docstring contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF002)
342-342: Docstring contains ambiguous) (FULLWIDTH RIGHT PARENTHESIS). Did you mean) (RIGHT PARENTHESIS)?
(RUF002)
353-353: Do not catch blind exception:Exception
(BLE001)
354-354: Comment contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF003)
355-355:jm_log may be undefined, or defined from star imports
(F405)
🔇 Additional comments (6)
assets/option/option_test_api.yml (1)
4-4:LGTM!The configuration addition correctly enables Simplified Chinese normalization for directory names, aligning with the PR's objective to prevent duplicate directories caused by Chinese variant differences.
src/jmcomic/jm_option.py (4)
2-2:LGTM!The import of
JmcomicTextis necessary for the Chinese normalization functionality added in this PR.
98-100:LGTM!The normalization logic is correctly placed after rule parsing but before Windows path normalization. The implementation properly:
- Skips base directory paths
- Converts to string before normalization
- Falls back gracefully if zhconv is unavailable or normalization fails
213-213:LGTM!The defensive use of
getattrwith a default value ensures backward compatibility with existingDirRuleinstances that may not have thenormalize_zhattribute.
339-339:LGTM!The propagation in
deconstructmirrors the approach incopy_option, ensuring the configuration is properly serialized. The defensivegetattrmaintains backward compatibility.src/jmcomic/jm_toolkit.py (1)
335-356:LGTM! Robust error handling with appropriate fallback behavior.The implementation correctly:
- Handles None inputs gracefully
- Uses zhconv for conversion when available
- Falls back to the original string on any error (missing library, invalid target, conversion failure)
- Logs errors for debugging without breaking functionality
This defensive approach aligns with the PR's goal of avoiding disruption when normalization cannot be performed.
The broad
Exceptioncatch is appropriate here despite the static analysis warning, as it ensures graceful degradation when zhconv is unavailable or encounters unexpected issues.Based on static analysis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/jmcomic/jm_option.py (1)
64-73:Minor: Use ASCII comma in docstring parameter description.The
normalize_zhparameter is correctly added and stored. However, the docstring uses a fullwidth comma (Chinese punctuation) which should be an ASCII comma for consistency.Apply this diff to fix the punctuation:
def __init__(self, rule: str, base_dir=None, normalize_zh=None): """ :param rule: DSL rule :param base_dir: base directory- :param normalize_zh: 'zh-cn'|'zh-tw'| or None. 控制是否以及如何进行繁简体归一化,默认 None+ :param normalize_zh: 'zh-cn'|'zh-tw'| or None. 控制是否以及如何进行繁简体归一化, 默认 None """
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/jmcomic/jm_config.py(1 hunks)src/jmcomic/jm_option.py(5 hunks)src/jmcomic/jm_toolkit.py(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/jmcomic/jm_config.py
🧰 Additional context used
🧬 Code graph analysis (2)
src/jmcomic/jm_option.py (1)
src/jmcomic/jm_toolkit.py (3)
JmcomicText(6-355)parse_to_abspath(239-240)to_zh(336-351)
src/jmcomic/jm_toolkit.py (1)
src/jmcomic/jm_config.py (1)
jm_log(383-385)
🪛 Ruff (0.14.1)
src/jmcomic/jm_option.py
68-68: Docstring contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF002)
100-100:fix_windir_name may be undefined, or defined from star imports
(F405)
src/jmcomic/jm_toolkit.py
332-332: Comment contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF003)
352-352: Expectedexcept orfinally aftertry block
(invalid-syntax)
352-352: Expected a statement
(invalid-syntax)
352-352: Expected a statement
(invalid-syntax)
352-352: Expected a statement
(invalid-syntax)
353-353: Unexpected indentation
(invalid-syntax)
354-354: unindent does not match any outer indentation level
(invalid-syntax)
354-354: Expected a statement
(invalid-syntax)
354-354: Expected a statement
(invalid-syntax)
354-355: Expected an expression
(invalid-syntax)
355-355: Unexpected indentation
(invalid-syntax)
355-356: Expected an indented block afterif statement
(invalid-syntax)
356-356: Expected a statement
(invalid-syntax)
356-356: Expected a statement
(invalid-syntax)
356-356: Expected a statement
(invalid-syntax)
356-356: Expected a statement
(invalid-syntax)
356-357: Expected a statement
(invalid-syntax)
357-357: Unexpected indentation
(invalid-syntax)
358-358: Unexpected indentation
(invalid-syntax)
365-365: Expectedexcept orfinally aftertry block
(invalid-syntax)
366-366: unindent does not match any outer indentation level
(invalid-syntax)
366-366: Expected a statement
(invalid-syntax)
366-366: Expected a statement
(invalid-syntax)
366-367: Expected an expression
(invalid-syntax)
367-367: Comment contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF003)
368-368: Expected a statement
(invalid-syntax)
368-368: Expected a statement
(invalid-syntax)
368-368: Expected a statement
(invalid-syntax)
368-368: Expected a statement
(invalid-syntax)
368-368: Expected ',', found float
(invalid-syntax)
368-368: Expected ',', found ':'
(invalid-syntax)
368-368: Expected ',', found name
(invalid-syntax)
368-368: Expected ',', found name
(invalid-syntax)
368-368: Expected ',', found name
(invalid-syntax)
368-368: Got unexpected token ,
(invalid-syntax)
368-368: Expected ',', found name
(invalid-syntax)
368-368: Expected ',', found name
(invalid-syntax)
369-369: Unexpected indentation
(invalid-syntax)
🔇 Additional comments (5)
src/jmcomic/jm_toolkit.py (1)
331-333:LGTM: Clean refactoring to delegate to the new generic method.The refactoring of
to_zh_cnto delegate toto_zh(s, 'zh-cn')is correct and maintains backward compatibility while reducing code duplication.src/jmcomic/jm_option.py (4)
2-2:LGTM: Import added for Chinese normalization support.The import of
JmcomicTextis correctly added to support the new Chinese normalization functionality.
98-100:LGTM: Chinese normalization correctly applied before Windows path sanitization.The Chinese normalization is applied at the right point in the flow:
- After parsing the rule to get the path component
- Before Windows path name sanitization
- Only for non-base-dir paths
This ensures consistent directory naming regardless of simplified/traditional Chinese variants in the source data.
208-220:LGTM: normalize_zh properly propagated in copy_option.The
normalize_zhfield is correctly included when creating a copy of the option, ensuring the configuration is preserved.
332-344:LGTM: normalize_zh included in option serialization.The
normalize_zhfield is correctly included in thedeconstructmethod, ensuring it's properly serialized when saving the option to a file.
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/jmcomic/jm_toolkit.py (1)
335-359:Merge conflict resolved correctly with improved error handling.The implementation successfully resolves the previously flagged merge conflict and improves upon the suggested fix by separating ImportError (with a user-friendly installation message) from general exceptions (with debug information).
However, there's a minor improvement opportunity: the
ImportErrorexception on Line 353 is assigned toebut not used in the log message on Line 354. While the friendly message is helpful, including the exception details would aid debugging.Consider logging the exception in the ImportError block for better debugging:
except ImportError as e:- jm_log('zhconv.error', '繁简转换失败,未安装zhconv,请先使用命令安装: [pip install zhconv]')+ jm_log('zhconv.error', f'繁简转换失败,未安装zhconv,请先使用命令安装: [pip install zhconv]. Error: {e}') return sNote: The fullwidth commas (,) in the Chinese strings are flagged by static analysis but are likely intentional for proper Chinese punctuation. The blind
Exceptioncatch on Line 356 is acceptable here as a graceful fallback mechanism.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/jmcomic/__init__.py(1 hunks)src/jmcomic/jm_config.py(1 hunks)src/jmcomic/jm_toolkit.py(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/jmcomic/jm_toolkit.py (1)
src/jmcomic/jm_config.py (1)
jm_log(383-385)
🪛 Ruff (0.14.1)
src/jmcomic/jm_toolkit.py
332-332: Comment contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF003)
341-341: Docstring contains ambiguous( (FULLWIDTH LEFT PARENTHESIS). Did you mean( (LEFT PARENTHESIS)?
(RUF002)
341-341: Docstring contains ambiguous) (FULLWIDTH RIGHT PARENTHESIS). Did you mean) (RIGHT PARENTHESIS)?
(RUF002)
341-341: Docstring contains ambiguous( (FULLWIDTH LEFT PARENTHESIS). Did you mean( (LEFT PARENTHESIS)?
(RUF002)
341-341: Docstring contains ambiguous) (FULLWIDTH RIGHT PARENTHESIS). Did you mean) (RIGHT PARENTHESIS)?
(RUF002)
341-341: Docstring contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF002)
342-342: Docstring contains ambiguous( (FULLWIDTH LEFT PARENTHESIS). Did you mean( (LEFT PARENTHESIS)?
(RUF002)
342-342: Docstring contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF002)
342-342: Docstring contains ambiguous) (FULLWIDTH RIGHT PARENTHESIS). Did you mean) (RIGHT PARENTHESIS)?
(RUF002)
353-353: Local variablee is assigned to but never used
Remove assignment to unused variablee
(F841)
354-354:jm_log may be undefined, or defined from star imports
(F405)
354-354: String contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF001)
354-354: String contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF001)
356-356: Do not catch blind exception:Exception
(BLE001)
357-357: Comment contains ambiguous, (FULLWIDTH COMMA). Did you mean, (COMMA)?
(RUF003)
358-358:jm_log may be undefined, or defined from star imports
(F405)
🔇 Additional comments (3)
src/jmcomic/jm_config.py (1)
414-414:LGTM! Configuration addition is clean.The
normalize_zh: Noneaddition todir_rulemaintains backward compatibility by defaulting to off. This aligns with the PR objective to provide optional Chinese text normalization without changing existing behavior.src/jmcomic/__init__.py (1)
5-5:Version bump looks good.Standard version increment to reflect the new
normalize_zhfeature.src/jmcomic/jm_toolkit.py (1)
331-333:Good backward compatibility approach.The
to_zh_cnwrapper correctly delegates to the newto_zhmethod, maintaining compatibility with existing callers.
92f8b26 intomasterUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
简介
本次 PR 为
dir_rule增加了对中文变体规范化(简/繁)的支持,解决了因简繁差异导致的重复目录或不一致命名问题。背景
在某些漫画源中,同一作品名称在简体/繁体之间存在差异(例如“漫画名” vs “漫畫名”),当目录规则未统一处理中文变体时,可能会生成重复或不一致的目录结构。该 PR 针对该问题在目录名生成流程中增加了可配置的中文规范化选项,以便统一命名。
解决方案
dir_rule下的配置项normalize_zh(可选),用于指示是否对目录/文件名中的中文进行规范化,以及规范化的目标变体(例如:simplified/traditional/off)。主要改动(概要)
dir_rule.normalize_zh的声明与说明,支持用户通过配置文件开启或关闭并选择目标变体。向后兼容性
normalize_zh并选择目标变体。验证建议
normalize_zh为simplified或traditional后,生成的目录名按配置统一且不会重复。关联 Issue
Fixes#485
如果你希望我把正文再补充更具体的实现细节(例如列出具体修改的文件路径、函数名或示例配置片段),我可以基于 PR 的改动把这些信息加入到说明中。
Summary by CodeRabbit
New Features
Chores
Documentation
Other