Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
skill_tree_devops
提交
926d4008
S
skill_tree_devops
项目概览
CSDN 技术社区
/
skill_tree_devops
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
skill_tree_devops
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
926d4008
编写于
12月 30, 2021
作者:
L
luxin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add keywords_must and keywords_forbid
上级
a9143c3f
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
144 addition
and
52 deletion
+144
-52
data/1.运维初阶/1.运维基础/1.Shell/config.json
data/1.运维初阶/1.运维基础/1.Shell/config.json
+21
-15
data/1.运维初阶/1.运维基础/1.Shell/helloworld.json
data/1.运维初阶/1.运维基础/1.Shell/helloworld.json
+6
-3
data/1.运维初阶/1.运维基础/config.json
data/1.运维初阶/1.运维基础/config.json
+4
-1
data/1.运维初阶/config.json
data/1.运维初阶/config.json
+4
-1
data/2.运维中阶/config.json
data/2.运维中阶/config.json
+4
-1
data/3.运维高阶/config.json
data/3.运维高阶/config.json
+4
-1
data/config.json
data/config.json
+3
-1
data/tree.json
data/tree.json
+30
-6
src/tree.py
src/tree.py
+68
-23
未找到文件。
data/1.运维初阶/1.运维基础/1.Shell/config.json
浏览文件 @
926d4008
{
{
"node_id"
:
"devops-6f0f3d97e7c144baaaf1b82c7a92252f"
,
"node_id"
:
"devops-6f0f3d97e7c144baaaf1b82c7a92252f"
,
"keywords"
:
[],
"keywords"
:
[],
"children"
:
[
"children"
:
[
{
{
"运维入门"
:
{
"运维入门"
:
{
"keywords"
:
[
"keywords"
:
[
"运维是做什么"
"运维是做什么"
],
],
"children"
:
[]
"children"
:
[],
}
"keywords_must"
:
[],
}
"keywords_forbid"
:
[],
],
"node_id"
:
"devops-62f278976e32425a930fc6e91902f4bc"
"export"
:
[
}
"helloworld.json"
}
]
],
"export"
:
[
"helloworld.json"
],
"keywords_must"
:
[],
"keywords_forbid"
:
[]
}
}
\ No newline at end of file
data/1.运维初阶/1.运维基础/1.Shell/helloworld.json
浏览文件 @
926d4008
{
{
"type"
:
"code_options"
,
"type"
:
"code_options"
,
"author"
:
"huanhuilong"
,
"author"
:
"huanhuilong"
,
"source"
:
"helloworld.md"
"source"
:
"helloworld.md"
,
"exercise_id"
:
"29a90053e0da4055b8e3d1790874d776"
,
"notebook_enable"
:
false
}
}
\ No newline at end of file
data/1.运维初阶/1.运维基础/config.json
浏览文件 @
926d4008
{
{
"node_id"
:
"devops-00e6b52067d54d4887631d8d0c99fa67"
,
"node_id"
:
"devops-00e6b52067d54d4887631d8d0c99fa67"
,
"keywords"
:
[]
"keywords"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[]
}
}
\ No newline at end of file
data/1.运维初阶/config.json
浏览文件 @
926d4008
{
{
"node_id"
:
"devops-296bbd7f39b2499bb2a30969bbeb870d"
,
"node_id"
:
"devops-296bbd7f39b2499bb2a30969bbeb870d"
,
"keywords"
:
[]
"keywords"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[]
}
}
\ No newline at end of file
data/2.运维中阶/config.json
浏览文件 @
926d4008
{
{
"node_id"
:
"devops-2d88d2335be74101b0ae72e6540f15a8"
,
"node_id"
:
"devops-2d88d2335be74101b0ae72e6540f15a8"
,
"keywords"
:
[]
"keywords"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[]
}
}
\ No newline at end of file
data/3.运维高阶/config.json
浏览文件 @
926d4008
{
{
"node_id"
:
"devops-aebee081f3cb4e71975041f45a517604"
,
"node_id"
:
"devops-aebee081f3cb4e71975041f45a517604"
,
"keywords"
:
[]
"keywords"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[]
}
}
\ No newline at end of file
data/config.json
浏览文件 @
926d4008
{
{
"tree_name"
:
"devops"
,
"tree_name"
:
"devops"
,
"keywords"
:
[],
"keywords"
:
[],
"node_id"
:
"devops-0d3595ca328c49388b409e8d5ba18a9a"
"node_id"
:
"devops-0d3595ca328c49388b409e8d5ba18a9a"
,
"keywords_must"
:
[],
"keywords_forbid"
:
[]
}
}
\ No newline at end of file
data/tree.json
浏览文件 @
926d4008
...
@@ -17,29 +17,53 @@
...
@@ -17,29 +17,53 @@
"Shell"
:
{
"Shell"
:
{
"node_id"
:
"devops-6f0f3d97e7c144baaaf1b82c7a92252f"
,
"node_id"
:
"devops-6f0f3d97e7c144baaaf1b82c7a92252f"
,
"keywords"
:
[],
"keywords"
:
[],
"children"
:
[]
"children"
:
[
{
"运维入门"
:
{
"keywords"
:
[
"运维是做什么"
],
"children"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"node_id"
:
"devops-62f278976e32425a930fc6e91902f4bc"
}
}
],
"keywords_must"
:
[],
"keywords_forbid"
:
[]
}
}
}
}
]
],
"keywords_must"
:
[],
"keywords_forbid"
:
[]
}
}
}
}
]
],
"keywords_must"
:
[],
"keywords_forbid"
:
[]
}
}
},
},
{
{
"运维中阶"
:
{
"运维中阶"
:
{
"node_id"
:
"devops-2d88d2335be74101b0ae72e6540f15a8"
,
"node_id"
:
"devops-2d88d2335be74101b0ae72e6540f15a8"
,
"keywords"
:
[],
"keywords"
:
[],
"children"
:
[]
"children"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[]
}
}
},
},
{
{
"运维高阶"
:
{
"运维高阶"
:
{
"node_id"
:
"devops-aebee081f3cb4e71975041f45a517604"
,
"node_id"
:
"devops-aebee081f3cb4e71975041f45a517604"
,
"keywords"
:
[],
"keywords"
:
[],
"children"
:
[]
"children"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[]
}
}
}
}
]
],
"keywords_must"
:
[],
"keywords_forbid"
:
[]
}
}
}
}
\ No newline at end of file
src/tree.py
浏览文件 @
926d4008
...
@@ -2,10 +2,10 @@ import json
...
@@ -2,10 +2,10 @@ import json
import
logging
import
logging
import
os
import
os
import
re
import
re
import
subprocess
import
sys
import
sys
import
uuid
import
uuid
import
re
import
re
import
git
id_set
=
set
()
id_set
=
set
()
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -14,15 +14,31 @@ handler = logging.StreamHandler(sys.stdout)
...
@@ -14,15 +14,31 @@ handler = logging.StreamHandler(sys.stdout)
formatter
=
logging
.
Formatter
(
'%(asctime)s - %(levelname)s - %(message)s'
)
formatter
=
logging
.
Formatter
(
'%(asctime)s - %(levelname)s - %(message)s'
)
handler
.
setFormatter
(
formatter
)
handler
.
setFormatter
(
formatter
)
logger
.
addHandler
(
handler
)
logger
.
addHandler
(
handler
)
repo
=
git
.
Repo
(
"."
)
def
user_name
():
def
search_author
(
author_dict
,
username
):
return
repo
.
config_reader
().
get_value
(
"user"
,
"name"
)
for
key
in
author_dict
:
names
=
author_dict
[
key
]
if
username
in
names
:
return
key
return
username
def
user_name
(
md_file
,
author_dict
):
ret
=
subprocess
.
Popen
([
"git"
,
"log"
,
md_file
],
stdout
=
subprocess
.
PIPE
)
lines
=
list
(
map
(
lambda
l
:
l
.
decode
(),
ret
.
stdout
.
readlines
()))
author_lines
=
[]
for
line
in
lines
:
if
line
.
startswith
(
'Author'
):
author_lines
.
append
(
line
.
split
(
' '
)[
1
])
author_nick_name
=
author_lines
[
-
1
]
return
search_author
(
author_dict
,
author_nick_name
)
def
load_json
(
p
):
def
load_json
(
p
):
with
open
(
p
,
'r'
)
as
f
:
with
open
(
p
,
'r'
,
encoding
=
"utf-8"
)
as
f
:
return
json
.
loads
(
f
.
read
())
return
json
.
loads
(
f
.
read
())
...
@@ -77,7 +93,18 @@ def check_export(base, cfg):
...
@@ -77,7 +93,18 @@ def check_export(base, cfg):
class
TreeWalker
:
class
TreeWalker
:
def
__init__
(
self
,
root
,
tree_name
,
title
=
None
,
log
=
None
):
def
__init__
(
self
,
root
,
tree_name
,
title
=
None
,
log
=
None
,
authors
=
None
,
enable_notebook
=
None
,
ignore_keywords
=
False
):
self
.
ignore_keywords
=
ignore_keywords
self
.
authors
=
authors
if
authors
else
{}
self
.
enable_notebook
=
enable_notebook
self
.
name
=
tree_name
self
.
name
=
tree_name
self
.
root
=
root
self
.
root
=
root
self
.
title
=
tree_name
if
title
is
None
else
title
self
.
title
=
tree_name
if
title
is
None
else
title
...
@@ -89,7 +116,9 @@ class TreeWalker:
...
@@ -89,7 +116,9 @@ class TreeWalker:
root_node
=
{
root_node
=
{
"node_id"
:
root
[
"node_id"
],
"node_id"
:
root
[
"node_id"
],
"keywords"
:
root
[
"keywords"
],
"keywords"
:
root
[
"keywords"
],
"children"
:
[]
"children"
:
[],
"keywords_must"
:
root
[
"keywords_must"
],
"keywords_forbid"
:
root
[
"keywords_forbid"
]
}
}
self
.
tree
[
root
[
"tree_name"
]]
=
root_node
self
.
tree
[
root
[
"tree_name"
]]
=
root_node
self
.
load_levels
(
root_node
)
self
.
load_levels
(
root_node
)
...
@@ -144,6 +173,8 @@ class TreeWalker:
...
@@ -144,6 +173,8 @@ class TreeWalker:
"node_id"
:
config
[
"node_id"
],
"node_id"
:
config
[
"node_id"
],
"keywords"
:
config
[
"keywords"
],
"keywords"
:
config
[
"keywords"
],
"children"
:
[],
"children"
:
[],
"keywords_must"
:
config
[
"keywords_must"
],
"keywords_forbid"
:
config
[
"keywords_forbid"
]
}
}
}
}
...
@@ -195,6 +226,8 @@ class TreeWalker:
...
@@ -195,6 +226,8 @@ class TreeWalker:
"tree_name"
:
self
.
name
,
"tree_name"
:
self
.
name
,
"keywords"
:
[],
"keywords"
:
[],
"node_id"
:
self
.
gen_node_id
(),
"node_id"
:
self
.
gen_node_id
(),
"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
:
...
@@ -224,7 +257,9 @@ class TreeWalker:
...
@@ -224,7 +257,9 @@ class TreeWalker:
if
not
os
.
path
.
exists
(
config_path
):
if
not
os
.
path
.
exists
(
config_path
):
config
=
{
config
=
{
"node_id"
:
self
.
gen_node_id
(),
"node_id"
:
self
.
gen_node_id
(),
"keywords"
:
[]
"keywords"
:
[],
"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
:
...
@@ -290,6 +325,8 @@ class TreeWalker:
...
@@ -290,6 +325,8 @@ class TreeWalker:
"node_id"
:
config
[
"node_id"
],
"node_id"
:
config
[
"node_id"
],
"keywords"
:
config
[
"keywords"
],
"keywords"
:
config
[
"keywords"
],
"children"
:
[],
"children"
:
[],
"keywords_must"
:
config
[
"keywords_must"
],
"keywords_forbid"
:
config
[
"keywords_forbid"
]
}
}
}
}
return
num
,
result
return
num
,
result
...
@@ -301,7 +338,9 @@ class TreeWalker:
...
@@ -301,7 +338,9 @@ class TreeWalker:
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"
,
[]),
"keywords_must"
:
config
[
"keywords_must"
],
"keywords_forbid"
:
config
[
"keywords_forbid"
]
}
}
}
}
# if "children" in config:
# if "children" in config:
...
@@ -318,7 +357,8 @@ class TreeWalker:
...
@@ -318,7 +357,8 @@ class TreeWalker:
continue
continue
mfile
=
base
+
".json"
mfile
=
base
+
".json"
meta_path
=
os
.
path
.
join
(
section_path
,
mfile
)
meta_path
=
os
.
path
.
join
(
section_path
,
mfile
)
self
.
ensure_exercises_meta
(
meta_path
,
source
)
md_file
=
os
.
path
.
join
(
section_path
,
e
)
self
.
ensure_exercises_meta
(
meta_path
,
source
,
md_file
)
export
=
config
.
get
(
"export"
,
[])
export
=
config
.
get
(
"export"
,
[])
if
mfile
not
in
export
and
self
.
name
!=
"algorithm"
:
if
mfile
not
in
export
and
self
.
name
!=
"algorithm"
:
export
.
append
(
mfile
)
export
.
append
(
mfile
)
...
@@ -339,7 +379,7 @@ class TreeWalker:
...
@@ -339,7 +379,7 @@ class TreeWalker:
else
:
else
:
id_set
.
add
(
exercise
[
"exercise_id"
])
id_set
.
add
(
exercise
[
"exercise_id"
])
def
ensure_exercises_meta
(
self
,
meta_path
,
source
):
def
ensure_exercises_meta
(
self
,
meta_path
,
source
,
md_file
):
_
,
mfile
=
os
.
path
.
split
(
meta_path
)
_
,
mfile
=
os
.
path
.
split
(
meta_path
)
meta
=
None
meta
=
None
if
os
.
path
.
exists
(
meta_path
):
if
os
.
path
.
exists
(
meta_path
):
...
@@ -354,27 +394,32 @@ class TreeWalker:
...
@@ -354,27 +394,32 @@ class TreeWalker:
if
"source"
not
in
meta
:
if
"source"
not
in
meta
:
meta
[
"source"
]
=
source
meta
[
"source"
]
=
source
if
"author"
not
in
meta
:
if
"author"
not
in
meta
:
meta
[
"author"
]
=
user_name
()
meta
[
"author"
]
=
user_name
(
md_file
,
self
.
authors
)
if
"type"
not
in
meta
:
if
"type"
not
in
meta
:
meta
[
"type"
]
=
"code_options"
meta
[
"type"
]
=
"code_options"
if
meta
is
None
:
meta
=
{
if
meta
is
None
:
"type"
:
"code_options"
,
meta
=
{
"author"
:
user_name
(),
"type"
:
"code_options"
,
"source"
:
source
,
"author"
:
user_name
(
md_file
,
self
.
authors
),
"notebook_enable"
:
self
.
default_notebook
(),
"source"
:
source
,
"exercise_id"
:
uuid
.
uuid4
().
hex
"notebook_enable"
:
self
.
default_notebook
(),
}
"exercise_id"
:
uuid
.
uuid4
().
hex
}
dump_json
(
meta_path
,
meta
,
True
,
True
)
dump_json
(
meta_path
,
meta
,
True
,
True
)
def
default_notebook
(
self
):
def
default_notebook
(
self
):
if
self
.
enable_notebook
is
not
None
:
return
self
.
enable_notebook
if
self
.
name
in
[
"python"
,
"java"
,
"c"
]:
if
self
.
name
in
[
"python"
,
"java"
,
"c"
]:
return
True
return
True
else
:
else
:
return
False
return
False
def
check_section_keywords
(
self
,
full_path
):
def
check_section_keywords
(
self
,
full_path
):
if
self
.
ignore_keywords
:
return
config
=
self
.
ensure_section_config
(
full_path
)
config
=
self
.
ensure_section_config
(
full_path
)
#
if not config.get("keywords", []):
if
not
config
.
get
(
"keywords"
,
[]):
#
self.logger.error(f"节点 [{full_path}] 的关键字为空,请修改配置文件写入关键字")
self
.
logger
.
error
(
f
"节点 [
{
full_path
}
] 的关键字为空,请修改配置文件写入关键字"
)
#
sys.exit(1)
sys
.
exit
(
1
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录