Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
skill_tree_algorithm
提交
23bc0846
S
skill_tree_algorithm
项目概览
CSDN 技术社区
/
skill_tree_algorithm
通知
9
Star
8
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
skill_tree_algorithm
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
23bc0846
编写于
11月 09, 2021
作者:
F
feilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug
上级
f3356501
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
4 addition
and
10 deletion
+4
-10
src/tree.py
src/tree.py
+4
-10
未找到文件。
src/tree.py
浏览文件 @
23bc0846
...
@@ -51,8 +51,6 @@ def parse_no_name(d):
...
@@ -51,8 +51,6 @@ def parse_no_name(d):
no
=
int
(
m
.
group
(
1
))
no
=
int
(
m
.
group
(
1
))
dir_name
=
m
.
group
(
2
)
dir_name
=
m
.
group
(
2
)
except
:
except
:
logger
.
error
(
'parser no name failed'
)
logger
.
error
(
d
)
sys
.
exit
(
0
)
sys
.
exit
(
0
)
return
no
,
dir_name
return
no
,
dir_name
...
@@ -108,11 +106,9 @@ class TreeWalker:
...
@@ -108,11 +106,9 @@ class TreeWalker:
for
index
,
section_node
in
enumerate
(
chapter_node
[
"children"
]):
for
index
,
section_node
in
enumerate
(
chapter_node
[
"children"
]):
section_title
=
list
(
section_node
.
keys
())[
0
]
section_title
=
list
(
section_node
.
keys
())[
0
]
full_path
=
os
.
path
.
join
(
full_path
=
os
.
path
.
join
(
chapter_path
,
f
"
{
section_title
}
"
)
chapter_path
,
f
"
{
index
}
.
{
section_title
}
"
)
if
os
.
path
.
isdir
(
full_path
):
if
os
.
path
.
isdir
(
full_path
):
self
.
ensure_exercises
(
full_path
)
self
.
ensure_exercises
(
full_path
)
else
:
pass
tree_path
=
os
.
path
.
join
(
self
.
root
,
"tree.json"
)
tree_path
=
os
.
path
.
join
(
self
.
root
,
"tree.json"
)
dump_json
(
tree_path
,
self
.
tree
,
exist_ok
=
True
,
override
=
True
)
dump_json
(
tree_path
,
self
.
tree
,
exist_ok
=
True
,
override
=
True
)
...
@@ -165,8 +161,6 @@ class TreeWalker:
...
@@ -165,8 +161,6 @@ class TreeWalker:
sections
.
append
((
num
,
section
))
sections
.
append
((
num
,
section
))
sections
.
sort
(
key
=
lambda
item
:
item
[
0
])
sections
.
sort
(
key
=
lambda
item
:
item
[
0
])
for
item
in
sections
:
item
[
1
][
'origin_num'
]
=
item
[
0
]
chapter_node
[
"children"
]
=
[
item
[
1
]
for
item
in
sections
]
chapter_node
[
"children"
]
=
[
item
[
1
]
for
item
in
sections
]
return
chapter_node
return
chapter_node
...
@@ -250,7 +244,7 @@ class TreeWalker:
...
@@ -250,7 +244,7 @@ class TreeWalker:
def
extract_node_env
(
self
,
path
):
def
extract_node_env
(
self
,
path
):
try
:
try
:
_
,
dir
=
os
.
path
.
split
(
path
)
_
,
dir
=
os
.
path
.
split
(
path
)
#
self.logger.info(path)
self
.
logger
.
info
(
path
)
number
,
title
=
dir
.
split
(
"."
,
1
)
number
,
title
=
dir
.
split
(
"."
,
1
)
return
int
(
number
),
title
return
int
(
number
),
title
except
Exception
as
error
:
except
Exception
as
error
:
...
@@ -273,7 +267,7 @@ class TreeWalker:
...
@@ -273,7 +267,7 @@ class TreeWalker:
config
=
self
.
ensure_section_config
(
full_name
)
config
=
self
.
ensure_section_config
(
full_name
)
num
,
name
=
self
.
extract_node_env
(
full_name
)
num
,
name
=
self
.
extract_node_env
(
full_name
)
result
=
{
result
=
{
f
"
{
num
}
.
{
name
}
"
:
{
name
:
{
"node_id"
:
config
[
"node_id"
],
"node_id"
:
config
[
"node_id"
],
"keywords"
:
config
[
"keywords"
],
"keywords"
:
config
[
"keywords"
],
"children"
:
config
.
get
(
"children"
,
[])
"children"
:
config
.
get
(
"children"
,
[])
...
@@ -290,4 +284,4 @@ class TreeWalker:
...
@@ -290,4 +284,4 @@ class TreeWalker:
exercise
=
load_json
(
full_name
)
exercise
=
load_json
(
full_name
)
if
"exercise_id"
not
in
exercise
:
if
"exercise_id"
not
in
exercise
:
exercise
[
"exercise_id"
]
=
uuid
.
uuid4
().
hex
exercise
[
"exercise_id"
]
=
uuid
.
uuid4
().
hex
dump_json
(
full_name
,
exercise
,
True
,
True
)
dump_json
(
full_name
,
exercise
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录