From 31050f0ccdaca2a184c779fac9d86cd212174e4b Mon Sep 17 00:00:00 2001 From: luxin Date: Tue, 16 Aug 2022 16:14:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20subtree=20=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++++ src/skill_tree/tree.py | 24 ++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c2b2ce8..d6a443d 100644 --- a/README.md +++ b/README.md @@ -46,3 +46,7 @@ CSDN 技能树结构(章节、元信息、习题)解释器,支持技能树 - 增加 FAQ - 修正 `requirements.txt` 包拼写错误 +### 0.0.13 + +- 增加 subtree 字段 + diff --git a/src/skill_tree/tree.py b/src/skill_tree/tree.py index cf20030..fb8bd2e 100644 --- a/src/skill_tree/tree.py +++ b/src/skill_tree/tree.py @@ -71,7 +71,8 @@ def ensure_config(path): node = {"keywords": [], "keywords_must": [], "keywords_forbid": [], - "group": 0} + "group": 0, + "subtree": ""} dump_json(config_path, node, exist_ok=True, override=False) return node else: @@ -132,7 +133,8 @@ class TreeWalker: "children": [], "keywords_must": root.get("keywords_must", []), "keywords_forbid": root.get("keywords_forbid", []), - "group": root.get("group", 0) + "group": root.get("group", 0), + "subtree": root.get("subtree", "") } self.tree[root["tree_name"]] = root_node self.load_levels(root_node) @@ -189,7 +191,8 @@ class TreeWalker: "children": [], "keywords_must": config.get("keywords_must", []), "keywords_forbid": config.get("keywords_forbid", []), - "group": config.get("group", 0) + "group": config.get("group", 0), + "subtree": config.get("subtree", "") } } @@ -243,7 +246,8 @@ class TreeWalker: "node_id": self.gen_node_id(), "keywords_must": [], "keywords_forbid": [], - "group": 0 + "group": 0, + "subtree": "" } dump_json(config_path, config, exist_ok=True, override=True) else: @@ -276,7 +280,8 @@ class TreeWalker: "keywords": [], "keywords_must": [], "keywords_forbid": [], - "group": 0 + "group": 0, + "subtree": "" } dump_json(config_path, config, exist_ok=True, override=True) else: @@ -296,7 +301,8 @@ class TreeWalker: "export": [], "keywords_must": [], "keywords_forbid": [], - "group": 0 + "group": 0, + "subtree": "" } dump_json(config_path, config, exist_ok=True, override=True) else: @@ -347,7 +353,8 @@ class TreeWalker: "children": [], "keywords_must": config.get("keywords_must", []), "keywords_forbid": config.get("keywords_forbid", []), - "group": config.get("group", 0) + "group": config.get("group", 0), + "subtree": config.get("subtree", "") } } return num, result @@ -362,7 +369,8 @@ class TreeWalker: "children": config.get("children", []), "keywords_must": config.get("keywords_must", []), "keywords_forbid": config.get("keywords_forbid", []), - "group": config.get("group", 0) + "group": config.get("group", 0), + "subtree": config.get("subtree", "") } } # if "children" in config: -- GitLab