From 23bc08460fe4a5edd0019815ec1e3dc884e53dd2 Mon Sep 17 00:00:00 2001 From: feilong Date: Tue, 9 Nov 2021 10:12:54 +0800 Subject: [PATCH] fix bug --- src/tree.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/tree.py b/src/tree.py index 89483a0d2..61b5b8950 100644 --- a/src/tree.py +++ b/src/tree.py @@ -51,8 +51,6 @@ def parse_no_name(d): no = int(m.group(1)) dir_name = m.group(2) except: - logger.error('parser no name failed') - logger.error(d) sys.exit(0) return no, dir_name @@ -108,11 +106,9 @@ class TreeWalker: for index, section_node in enumerate(chapter_node["children"]): section_title = list(section_node.keys())[0] full_path = os.path.join( - chapter_path, f"{section_title}") + chapter_path, f"{index}.{section_title}") if os.path.isdir(full_path): self.ensure_exercises(full_path) - else: - pass tree_path = os.path.join(self.root, "tree.json") dump_json(tree_path, self.tree, exist_ok=True, override=True) @@ -165,8 +161,6 @@ class TreeWalker: sections.append((num, section)) sections.sort(key=lambda item: item[0]) - for item in sections: - item[1]['origin_num'] = item[0] chapter_node["children"] = [item[1] for item in sections] return chapter_node @@ -250,7 +244,7 @@ class TreeWalker: def extract_node_env(self, path): try: _, dir = os.path.split(path) - # self.logger.info(path) + self.logger.info(path) number, title = dir.split(".", 1) return int(number), title except Exception as error: @@ -273,7 +267,7 @@ class TreeWalker: config = self.ensure_section_config(full_name) num, name = self.extract_node_env(full_name) result = { - f"{num}.{name}": { + name: { "node_id": config["node_id"], "keywords": config["keywords"], "children": config.get("children", []) @@ -290,4 +284,4 @@ class TreeWalker: exercise = load_json(full_name) if "exercise_id" not in exercise: exercise["exercise_id"] = uuid.uuid4().hex - dump_json(full_name, exercise, True, True) + dump_json(full_name, exercise) -- GitLab