From cf447881d46d9180da27a1c64ea1be8feb7b619d Mon Sep 17 00:00:00 2001 From: Mars Liu Date: Tue, 18 Jan 2022 16:06:51 +0800 Subject: [PATCH] 0.0.7 --- README.md | 5 ++++- setup.py | 2 +- src/skill_tree/tree.py | 12 ++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6995383..6fd4b7f 100644 --- a/README.md +++ b/README.md @@ -16,4 +16,7 @@ CSDN 技能树结构(章节、元信息、习题)解释器,支持技能树 - 捕获 json 文件编码错误 ### 0.0.6 - - 为 `keywords_must` 和 `keywords_forbid` 的读取操作添加默认值 \ No newline at end of file + - 为 `keywords_must` 和 `keywords_forbid` 的读取操作添加默认值 + +### 0.0.7 + - 为 config.json 添加默认的 `keywords_must` 和 `keywords_forbid` 空列表 \ No newline at end of file diff --git a/setup.py b/setup.py index f1b28b9..c76ae57 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ this_directory = Path(__file__).parent long_description = (this_directory / "README.md").read_text() setup(name="skill-tree-parser", - version="0.0.6", + version="0.0.7", description="CSDN Skill Tree Parser", long_description=long_description, long_description_content_type='text/markdown', diff --git a/src/skill_tree/tree.py b/src/skill_tree/tree.py index e53153f..a9386cc 100644 --- a/src/skill_tree/tree.py +++ b/src/skill_tree/tree.py @@ -64,7 +64,9 @@ def dump_json(p, j, exist_ok=False, override=False): def ensure_config(path): config_path = os.path.join(path, "config.json") if not os.path.exists(config_path): - node = {"keywords": []} + node = {"keywords": [], + "keywords_must": [], + "keywords_forbid": []} dump_json(config_path, node, exist_ok=True, override=False) return node else: @@ -121,7 +123,7 @@ class TreeWalker: root = self.load_root() root_node = { "node_id": root["node_id"], - "keywords": root["keywords"], + "keywords": root.get("keywords", []), "children": [], "keywords_must": root.get("keywords_must", []), "keywords_forbid": root.get("keywords_forbid", []) @@ -282,7 +284,9 @@ class TreeWalker: "node_id": self.gen_node_id(), "keywords": [], "children": [], - "export": [] + "export": [], + "keywords_must": [], + "keywords_forbid": [] } dump_json(config_path, config, exist_ok=True, override=True) else: @@ -343,7 +347,7 @@ class TreeWalker: result = { name: { "node_id": config["node_id"], - "keywords": config["keywords"], + "keywords": config.get("keywords", []), "children": config.get("children", []), "keywords_must": config.get("keywords_must", []), "keywords_forbid": config.get("keywords_forbid", []) -- GitLab