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

add auto method

上级 ab74bd1d
...@@ -8,6 +8,10 @@ CSDN 技能树结构(章节、元信息、习题)解释器,支持技能树 ...@@ -8,6 +8,10 @@ CSDN 技能树结构(章节、元信息、习题)解释器,支持技能树
## what's new ## what's new
### 0.0.5
- 修正错误的程序流程
### 0.0.4 ### 0.0.4
- 支持在习题中内嵌 markdown 源码 - 支持在习题中内嵌 markdown 源码
......
...@@ -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(encoding="utf-8") long_description = (this_directory / "README.md").read_text(encoding="utf-8")
setup(name="skill-tree-parser", setup(name="skill-tree-parser",
version="0.0.13", version="0.0.14",
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',
......
...@@ -162,6 +162,12 @@ class TreeWalker: ...@@ -162,6 +162,12 @@ class TreeWalker:
dump_json(tree_path, self.tree, exist_ok=True, override=True) dump_json(tree_path, self.tree, exist_ok=True, override=True)
return self.tree return self.tree
def auto(self):
if os.path.exists(self.root) and os.listdir(self.root):
self.walk()
else:
self.init()
def sort_dir_list(self, dirs): def sort_dir_list(self, dirs):
result = [self.extract_node_env(dir) for dir in dirs] result = [self.extract_node_env(dir) for dir in dirs]
result.sort(key=lambda item: item[0]) result.sort(key=lambda item: item[0])
...@@ -489,7 +495,7 @@ class TreeWalker: ...@@ -489,7 +495,7 @@ class TreeWalker:
sys.exit(1) sys.exit(1)
def init(self): def init(self):
data_root = 'data' data_root = self.root
os.makedirs(data_root, exist_ok=True) os.makedirs(data_root, exist_ok=True)
node_dirs = [ node_dirs = [
...@@ -508,7 +514,7 @@ class TreeWalker: ...@@ -508,7 +514,7 @@ class TreeWalker:
emit_answer(md, None) emit_answer(md, None)
emit_options(md, None) emit_options(md, None)
simple_list_md_dump(os.path.join( simple_list_md_dump(os.path.join(
node_dirs[len(node_dirs)-1], 'helloworld.md'), md) node_dirs[len(node_dirs) - 1], 'helloworld.md'), md)
self.walk() self.walk()
self.init_readme() self.init_readme()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册