提交 cf447881 编写于 作者: M Mars Liu

0.0.7

上级 2fa8945b
...@@ -16,4 +16,7 @@ CSDN 技能树结构(章节、元信息、习题)解释器,支持技能树 ...@@ -16,4 +16,7 @@ CSDN 技能树结构(章节、元信息、习题)解释器,支持技能树
- 捕获 json 文件编码错误 - 捕获 json 文件编码错误
### 0.0.6 ### 0.0.6
-`keywords_must``keywords_forbid` 的读取操作添加默认值 -`keywords_must``keywords_forbid` 的读取操作添加默认值
\ No newline at end of file
### 0.0.7
- 为 config.json 添加默认的 `keywords_must``keywords_forbid` 空列表
\ No newline at end of file
...@@ -7,7 +7,7 @@ this_directory = Path(__file__).parent ...@@ -7,7 +7,7 @@ this_directory = Path(__file__).parent
long_description = (this_directory / "README.md").read_text() long_description = (this_directory / "README.md").read_text()
setup(name="skill-tree-parser", setup(name="skill-tree-parser",
version="0.0.6", version="0.0.7",
description="CSDN Skill Tree Parser", description="CSDN Skill Tree Parser",
long_description=long_description, long_description=long_description,
long_description_content_type='text/markdown', long_description_content_type='text/markdown',
......
...@@ -64,7 +64,9 @@ def dump_json(p, j, exist_ok=False, override=False): ...@@ -64,7 +64,9 @@ def dump_json(p, j, exist_ok=False, override=False):
def ensure_config(path): def ensure_config(path):
config_path = os.path.join(path, "config.json") config_path = os.path.join(path, "config.json")
if not os.path.exists(config_path): 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) dump_json(config_path, node, exist_ok=True, override=False)
return node return node
else: else:
...@@ -121,7 +123,7 @@ class TreeWalker: ...@@ -121,7 +123,7 @@ class TreeWalker:
root = self.load_root() root = self.load_root()
root_node = { root_node = {
"node_id": root["node_id"], "node_id": root["node_id"],
"keywords": root["keywords"], "keywords": root.get("keywords", []),
"children": [], "children": [],
"keywords_must": root.get("keywords_must", []), "keywords_must": root.get("keywords_must", []),
"keywords_forbid": root.get("keywords_forbid", []) "keywords_forbid": root.get("keywords_forbid", [])
...@@ -282,7 +284,9 @@ class TreeWalker: ...@@ -282,7 +284,9 @@ class TreeWalker:
"node_id": self.gen_node_id(), "node_id": self.gen_node_id(),
"keywords": [], "keywords": [],
"children": [], "children": [],
"export": [] "export": [],
"keywords_must": [],
"keywords_forbid": []
} }
dump_json(config_path, config, exist_ok=True, override=True) dump_json(config_path, config, exist_ok=True, override=True)
else: else:
...@@ -343,7 +347,7 @@ class TreeWalker: ...@@ -343,7 +347,7 @@ class TreeWalker:
result = { result = {
name: { name: {
"node_id": config["node_id"], "node_id": config["node_id"],
"keywords": config["keywords"], "keywords": config.get("keywords", []),
"children": config.get("children", []), "children": config.get("children", []),
"keywords_must": config.get("keywords_must", []), "keywords_must": config.get("keywords_must", []),
"keywords_forbid": config.get("keywords_forbid", []) "keywords_forbid": config.get("keywords_forbid", [])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册