Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
skill_tree_opencv
提交
68889b1e
S
skill_tree_opencv
项目概览
CSDN 技术社区
/
skill_tree_opencv
通知
44
Star
9
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
2
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
skill_tree_opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
2
Issue
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
68889b1e
编写于
12月 17, 2021
作者:
F
feilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
重构脚本
上级
60703b7b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
45 addition
and
30 deletion
+45
-30
assets/author.json
assets/author.json
+0
-13
main.py
main.py
+18
-1
src/tree.py
src/tree.py
+27
-16
未找到文件。
assets/author.json
已删除
100644 → 0
浏览文件 @
60703b7b
{
"Python小白进阶"
:
"youcans"
,
"youcans"
:
"youcans"
,
"AI浩"
:
"hhhhhhhhhhwwwwwwwwww"
,
"hhhhhhhhhhwwwwwwwwww"
:
"hhhhhhhhhhwwwwwwwwww"
,
"吴佳WuJia"
:
"yvettewu"
,
"yvettewu"
:
"yvettewu"
,
"幻灰龙"
:
"huanhuilong"
,
"feilong"
:
"huanhuilong"
,
"huanhuilong"
:
"huanhuilong"
,
"xiaozhi_5638"
:
"xiaozhi_5638"
,
"请叫我卷福"
:
"xiaozhi_5638"
}
\ No newline at end of file
main.py
浏览文件 @
68889b1e
...
...
@@ -4,7 +4,24 @@ from src.doc import DocWalker
from
src.img
import
ImgWalker
if
__name__
==
'__main__'
:
walker
=
TreeWalker
(
"data"
,
"opencv"
,
"OpenCV"
)
walker
=
TreeWalker
(
"data"
,
"opencv"
,
"OpenCV"
,
ignore_keywords
=
True
,
enable_notebook
=
False
,
authors
=
{
"Python小白进阶"
:
"youcans"
,
"youcans"
:
"youcans"
,
"AI浩"
:
"hhhhhhhhhhwwwwwwwwww"
,
"hhhhhhhhhhwwwwwwwwww"
:
"hhhhhhhhhhwwwwwwwwww"
,
"吴佳WuJia"
:
"yvettewu"
,
"yvettewu"
:
"yvettewu"
,
"幻灰龙"
:
"huanhuilong"
,
"feilong"
:
"huanhuilong"
,
"huanhuilong"
:
"huanhuilong"
,
"xiaozhi_5638"
:
"xiaozhi_5638"
,
"请叫我卷福"
:
"xiaozhi_5638"
}
)
walker
.
walk
()
# doc = DocWalker('doc')
...
...
src/tree.py
浏览文件 @
68889b1e
...
...
@@ -6,12 +6,6 @@ import subprocess
import
sys
import
uuid
import
re
import
git
def
load_json
(
p
):
with
open
(
p
,
'r'
)
as
f
:
return
json
.
loads
(
f
.
read
())
id_set
=
set
()
...
...
@@ -21,11 +15,9 @@ handler = logging.StreamHandler(sys.stdout)
formatter
=
logging
.
Formatter
(
'%(asctime)s - %(levelname)s - %(message)s'
)
handler
.
setFormatter
(
formatter
)
logger
.
addHandler
(
handler
)
repo
=
git
.
Repo
(
"."
)
author_dict
=
load_json
(
'assets/author.json'
)
def
user_name
(
md_file
):
def
user_name
(
md_file
,
author_dict
):
ret
=
subprocess
.
Popen
([
"git"
,
"log"
,
md_file
],
stdout
=
subprocess
.
PIPE
)
...
...
@@ -36,7 +28,11 @@ def user_name(md_file):
author_lines
.
append
(
line
.
split
(
' '
)[
1
])
author_nick_name
=
author_lines
[
-
1
]
return
author_dict
.
get
(
author_nick_name
,
""
)
# return repo.config_reader().get_value("user", "name")
def
load_json
(
p
):
with
open
(
p
,
'r'
)
as
f
:
return
json
.
loads
(
f
.
read
())
def
dump_json
(
p
,
j
,
exist_ok
=
False
,
override
=
False
):
...
...
@@ -90,7 +86,18 @@ def check_export(base, cfg):
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
.
root
=
root
self
.
title
=
tree_name
if
title
is
None
else
title
...
...
@@ -369,7 +376,7 @@ class TreeWalker:
if
"source"
not
in
meta
:
meta
[
"source"
]
=
source
if
"author"
not
in
meta
:
meta
[
"author"
]
=
user_name
(
md_file
)
meta
[
"author"
]
=
user_name
(
md_file
,
self
.
authors
)
if
"type"
not
in
meta
:
meta
[
"type"
]
=
"code_options"
except
:
...
...
@@ -377,7 +384,7 @@ class TreeWalker:
if
meta
is
None
:
meta
=
{
"type"
:
"code_options"
,
"author"
:
user_name
(
md_file
),
"author"
:
user_name
(
md_file
,
self
.
authors
),
"source"
:
source
,
"notebook_enable"
:
self
.
default_notebook
(),
"exercise_id"
:
uuid
.
uuid4
().
hex
...
...
@@ -385,13 +392,17 @@ class TreeWalker:
dump_json
(
meta_path
,
meta
,
True
,
True
)
def
default_notebook
(
self
):
if
self
.
enable_notebook
is
not
None
:
return
self
.
enable_notebook
if
self
.
name
in
[
"python"
,
"java"
,
"c"
]:
return
True
else
:
return
False
def
check_section_keywords
(
self
,
full_path
):
if
self
.
ignore_keywords
:
return
config
=
self
.
ensure_section_config
(
full_path
)
#
if not config.get("keywords", []):
#
self.logger.error(f"节点 [{full_path}] 的关键字为空,请修改配置文件写入关键字")
#
sys.exit(1)
if
not
config
.
get
(
"keywords"
,
[]):
self
.
logger
.
error
(
f
"节点 [
{
full_path
}
] 的关键字为空,请修改配置文件写入关键字"
)
sys
.
exit
(
1
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录