diff --git a/src/tree.py b/src/tree.py index 692eff50aef8ea6a8dc683401930b5369f5ffef3..91d03cb86db125acd4578689f0f08ffd33fbccfc 100644 --- a/src/tree.py +++ b/src/tree.py @@ -101,6 +101,7 @@ class TreeWalker: section_title = list(section_node.keys())[0] full_path = os.path.join(chapter_path, f"{index + 1}.{section_title}") if os.path.isdir(full_path): + self.check_section_keywords(full_path) self.ensure_exercises(full_path) tree_path = os.path.join(self.root, "tree.json") @@ -309,3 +310,9 @@ class TreeWalker: dump_json(full_name, exercise, True, True) else: id_set.add(exercise["exercise_id"]) + + def check_section_keywords(self, full_path): + config = self.ensure_section_config(full_path) + if not config.get("keywords", []): + self.logger.error(f"节点 [{full_path}] 的关键字为空,请修改配置文件写入关键字") + sys.exit(1)