diff --git a/README.md b/README.md index c2b2ce853597b8eec8481ec818c93d72c5eb8d12..d6a443d0d55c6a028cf97d73c66f59585cdccc24 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 cf20030dd85808df7002f03df0180aca9b1224e1..fb8bd2e64166bcac5408312fdd9a695246a4d1a8 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: