From 5d150cd3e1c1588eef6d58c75897d3d74945f4d7 Mon Sep 17 00:00:00 2001 From: Mars Liu Date: Thu, 2 Dec 2021 17:11:12 +0800 Subject: [PATCH] fixed odd orders --- src/tree.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tree.py b/src/tree.py index 692eff5..91d03cb 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) -- GitLab