Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
openEuler-Advisor
提交
a01a5af7
O
openEuler-Advisor
项目概览
openeuler
/
openEuler-Advisor
通知
43
Star
4
Fork
4
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
openEuler-Advisor
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a01a5af7
编写于
6月 28, 2020
作者:
W
wangchuangGG
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modify Log
上级
3189b38a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
17 deletion
+17
-17
advisors/check_licenses.py
advisors/check_licenses.py
+17
-17
未找到文件。
advisors/check_licenses.py
浏览文件 @
a01a5af7
...
...
@@ -87,12 +87,12 @@ def get_contents(filename):
return
None
def
get_tarball_from_url
(
upstream_url
,
download_path
,
tar
fil
e
):
def
get_tarball_from_url
(
upstream_url
,
download_path
,
tar
packag
e
):
"""
Get tar package from url.
return: tar package path.
"""
tarball_path
=
download_path
+
"/"
+
tar
fil
e
tarball_path
=
download_path
+
"/"
+
tar
packag
e
if
not
os
.
path
.
isfile
(
tarball_path
):
download
.
do_curl
(
upstream_url
,
dest
=
tarball_path
)
return
tarball_path
...
...
@@ -104,30 +104,30 @@ def extract_tar(tarball_path, extraction_path):
If extract failed the program will exit.
"""
if
not
os
.
path
.
isfile
(
tarball_path
):
logging
.
error
(
"
{} is not a tarball file"
.
format
(
tarball_path
)
)
logging
.
error
(
"
%s is not a tarball file"
,
tarball_path
)
exit
(
1
)
with
tarfile
.
open
(
tarball_path
)
as
content
:
content
.
extractall
(
path
=
extraction_path
)
def
decode_license
(
license
,
charset
):
def
decode_license
(
license
_string
,
charset
):
"""
Decode the license string.
return the license string or nothing.
"""
if
not
charset
:
return
return
license
.
decode
(
charset
)
return
license
_string
.
decode
(
charset
)
def
add_license_from_spec_file
(
license
):
def
add_license_from_spec_file
(
spec_
license
):
"""
Add license to licenses_for_spec.
"""
if
license
in
licenses_for_spec
:
logging
.
debug
(
"the license was in licenses_for_spec:
{}"
.
format
(
license
)
)
if
spec_
license
in
licenses_for_spec
:
logging
.
debug
(
"the license was in licenses_for_spec:
%s"
,
spec_license
)
else
:
licenses_for_spec
.
append
(
license
)
licenses_for_spec
.
append
(
spec_
license
)
def
add_license_from_license_file
(
license
):
...
...
@@ -135,7 +135,7 @@ def add_license_from_license_file(license):
Add license to licenses_for_license.
"""
if
license
in
licenses_for_license
:
logging
.
debug
(
"the license was in licenses_for_license:
{}
\n
"
.
format
(
license
)
)
logging
.
debug
(
"the license was in licenses_for_license:
%s
\n
"
,
license
)
else
:
licenses_for_license
.
append
(
license
)
...
...
@@ -156,7 +156,7 @@ def scan_licenses(copying):
if
word
in
data
:
real_word
=
license_translations
.
get
(
word
,
word
)
add_license_from_license_file
(
real_word
)
logging
.
debug
(
"all licenses from license file is:
{}"
.
format
(
licenses_for_license
)
)
logging
.
debug
(
"all licenses from license file is:
%s"
,
licenses_for_license
)
def
scan_licenses_in_LICENSE
(
srcdir
):
...
...
@@ -215,7 +215,7 @@ def scan_licenses_in_SPEC(specfile):
the program will exit with an error.
"""
if
not
specfile
.
endswith
(
".spec"
):
logging
.
error
(
"
{} is not a spec file"
.
format
(
specfile
)
)
logging
.
error
(
"
%s is not a spec file"
,
specfile
)
exit
(
1
)
try
:
with
open
(
specfile
,
'r'
)
as
specfd
:
...
...
@@ -239,9 +239,9 @@ def scan_licenses_in_SPEC(specfile):
if
word
not
in
excludes
:
real_word
=
license_translations
.
get
(
word
,
word
)
logging
.
debug
(
"after translate license_string ==> "
"real_license:
{} ==> {}"
.
format
(
word
,
real_word
)
)
"real_license:
%s ==> %s"
,
word
,
real_word
)
add_license_from_spec_file
(
real_word
)
logging
.
debug
(
"
\n
all licenses from SPEC file is:
{}"
.
format
(
licenses_for_spec
)
)
logging
.
debug
(
"
\n
all licenses from SPEC file is:
%s"
,
licenses_for_spec
)
def
check_licenses_is_same
():
...
...
@@ -295,7 +295,7 @@ def read_licenses_translate_conf(filename):
conf_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
conf_path
=
os
.
path
.
join
(
conf_dir
,
filename
)
if
not
os
.
path
.
isfile
(
conf_path
):
logging
.
info
(
"not found the config file:
{}"
.
format
(
conf_path
)
)
logging
.
info
(
"not found the config file:
%s"
,
conf_path
)
return
with
open
(
conf_path
,
"r"
)
as
conf_file
:
for
line
in
conf_file
:
...
...
@@ -327,10 +327,10 @@ def process_licenses(args, download_path):
if
check_licenses_is_same
():
logging
.
info
(
"licenses from LICENSES are same as form SPEC:"
"
{} <==> {}"
.
format
(
licenses_for_license
,
licenses_for_spec
)
)
"
%s <==> %s"
,
licenses_for_license
,
licenses_for_spec
)
else
:
logging
.
info
(
"licenses from LICENSES are not same as form SPEC:"
"
{} <==> {}"
.
format
(
licenses_for_license
,
licenses_for_spec
)
)
"
%s <==> %s"
,
licenses_for_license
,
licenses_for_spec
)
if
args
.
writespec
:
overwrite_spec
(
specfile
)
exit
(
0
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录