-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v2.4.6: 实现对本子名称进行分词并提取原始名称;实现更便捷的自定义下载文件夹名机制、并跟进对应文档;内置一些更简洁的、可用作文件夹名… #172
Conversation
…的字段oname, idoname, authoroname.
WalkthroughThe update introduces a customizable directory naming feature for album downloads, allowing users to define folder structures via a new Changes
TipsChat with CodeRabbit Bot (
|
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.
Review Status
Actionable comments generated: 4
Configuration used: CodeRabbit UI
Files selected for processing (6)
- assets/docs/sources/tutorial/9_custom_download_dir_name.md (1 hunks)
- src/jmcomic/init.py (1 hunks)
- src/jmcomic/jm_config.py (1 hunks)
- src/jmcomic/jm_entity.py (5 hunks)
- src/jmcomic/jm_option.py (1 hunks)
- src/jmcomic/jm_toolkit.py (1 hunks)
Files skipped from review due to trivial changes (1)
- src/jmcomic/init.py
Additional comments: 12
assets/docs/sources/tutorial/9_custom_download_dir_name.md (1)
- 1-112: The tutorial documentation provides a clear and comprehensive guide on how to customize download folder names using the new
DirRule
configuration. The examples are well-illustrated and demonstrate the usage of custom fields and the associated processing functions. It is important to ensure that the code snippets are tested and work as intended to prevent any confusion for the users.src/jmcomic/jm_entity.py (8)
65-66: The implementation of the
author
property correctly raisesNotImplementedError
, ensuring that subclasses must provide their own implementation.69-87: The
oname
property is implemented to extract the original name of an album usingJmcomicText.parse_orig_album_name
. Ensure that theparse_orig_album_name
method is robust and handles edge cases as expected.90-106: The
authoroname
property concatenates the author and original name in a specific format. Verify that theauthor
property is correctly implemented in all subclasses to avoid runtime errors.109-114: The
idoname
property concatenates the ID and original name in a specific format. This property assumes that theid
property is correctly implemented in all subclasses.127-152: The
get_dirname
class method is implemented to support custom folder naming using advice functions fromJmModuleConfig.XFIELD_ADVICE
. Ensure that the advice functions are properly defined and tested for the expected behavior.179-179: The
index
inJmImageDetail
is now starting from 1, which aligns with the summary. Ensure that all related code that depends on theindex
value is updated accordingly to prevent off-by-one errors.237-240: The
tag
property inJmImageDetail
has been updated to include the index within the total number of photos. Verify that thefrom_photo
property is always set and that its length is correctly calculated to avoid division by zero or other runtime errors.355-359: The
create_image_detail
method inJmPhotoDetail
correctly increments the index by 1 to align with the new index assignment starting from 1. Ensure that this change is reflected in all places wherecreate_image_detail
is called.src/jmcomic/jm_option.py (2)
134-135: The lambda function
solve_func
now usesDetailEntity.get_dirname
statically. Verify thatDetailEntity.get_dirname
is intended to be used as a static method and that it can handle thedetail
argument appropriately.135-135: The function
fix_windir_name
used in the lambdasolve_func
is not defined within the provided code. Ensure that it is defined elsewhere in the codebase or imported correctly.src/jmcomic/jm_toolkit.py (1)
- 238-242: The
parse_orig_album_name
method returns the first word not enclosed in brackets. However, if the intention is to extract the original album name, this logic might not be sufficient for all cases. Verify that this method's behavior aligns with the expected functionality.
# 例如: | ||
# Amyname -> JmModuleConfig.AFIELD_ADVICE['myname'] = lambda album: "自定义名称" | ||
AFIELD_ADVICE = dict() | ||
PFIELD_ADVICE = dict() |
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.
The addition of AFIELD_ADVICE
and PFIELD_ADVICE
is consistent with the summary and seems to be implemented correctly. However, it would be beneficial to provide an example or documentation for PFIELD_ADVICE
similar to the one provided for AFIELD_ADVICE
to ensure clarity and ease of use for future developers.
def parse_dsl_text(cls, dsl_text: str) -> str: | ||
return cls.dsl_replacer.parse_dsl_text(dsl_text) |
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.
The parse_dsl_text
method seems to be a simple wrapper around dsl_replacer.parse_dsl_text
. If there's no additional logic planned for this method, consider whether this extra layer of abstraction is necessary, as it could be called directly.
j = title.find(bracket_map[c], i) | ||
ExceptionTool.require_true(j != -1, f'未闭合的 {c}{bracket_map[c]}: {title[i:]}') |
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.
The tokenize
method throws an exception if a closing bracket is not found. While this is a valid way to handle unmatched brackets, consider if there's a need to handle this more gracefully, such as skipping the unmatched bracket or logging a warning, depending on the application's requirements.
def to_zh_cn(cls, s): | ||
import zhconv | ||
return zhconv.convert(s, 'zh_cn') |
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.
The to_zh_cn
method correctly uses the zhconv
library to convert text to simplified Chinese. However, consider handling potential exceptions that may arise from the zhconv.convert
call, such as when the library is not installed or when it encounters an error during conversion.
…的字段oname, idoname, authoroname.
Summary by CodeRabbit
New Features
Enhancements
Documentation
Refactor
solve_func
accesses theget_dirname
method for consistency and maintainability.Bug Fixes
Chores
parse_to_abspath
method and added new utility methods for text processing.