INNER CODE UNIT · Python
check_all_chapters
voocel/ainovel-cli · scripts/check_chapter_wordcount.py:76
def check_all_chapters(directory: str, pattern: str = '第*.md', min_words: int = 3000) -> list:
"""检查目录下所有符合模式的章节文件"""
dir_path = Path(directory)
if not dir_path.exists():
print(f'错误: 目录不存在 - {directory}')
return []
chapter_files = sorted(dir_path.glob(pattern))
return [check_chapter(str(chapter_file), min_words) for chapter_file in chapter_files]
def print_results(results: list, min_words: int = 3000) -> None:
"""打印检查结果"""
if not results:
print('没有找到章节文件')
return
total_words = 0