Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
openEuler-Advisor
提交
2546fbe5
O
openEuler-Advisor
项目概览
openeuler
/
openEuler-Advisor
通知
36
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2546fbe5
编写于
5月 27, 2020
作者:
S
Shinwell Hu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
a simple script to query package maintainer
上级
03ede4ba
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
103 addition
and
0 deletion
+103
-0
who_maintain.py
who_maintain.py
+103
-0
未找到文件。
who_maintain.py
0 → 100755
浏览文件 @
2546fbe5
#!/usr/bin/python3
"""
This is a simple script to query that contact person for specific package
"""
import
urllib
import
urllib.request
import
argparse
import
yaml
import
re
# Useful default setting
headers
=
{
'User-Agent'
:
'Mozilla/5.0 (Windows NT 6.1; WOW 64; rv:23.0) Gecko/20100101 Firefox/23.0'
}
# known important information
sigs_url
=
"https://gitee.com/openeuler/community/raw/master/sig/sigs.yaml"
sigs_owner_url_template
=
"https://gitee.com/openeuler/community/raw/master/sig/{signame}/OWNERS"
specfile_url_template
=
"https://gitee.com/src-openeuler/{package}/raw/master/{specfile}"
specfile_exception_url
=
"https://gitee.com/shinwell_hu/openEuler-Advisor/raw/master/helper/specfile_exceptions.yaml"
def
get_gitee
(
url
):
req
=
urllib
.
request
.
Request
(
url
=
url
,
headers
=
headers
)
u
=
urllib
.
request
.
urlopen
(
req
)
return
u
.
read
().
decode
(
"utf-8"
)
def
get_sigs
():
req
=
urllib
.
request
.
Request
(
url
=
sigs_url
,
headers
=
headers
)
u
=
urllib
.
request
.
urlopen
(
req
)
sigs
=
yaml
.
load
(
u
.
read
().
decode
(
"utf-8"
),
Loader
=
yaml
.
Loader
)
return
sigs
def
get_spec
(
pkg
,
specfile
):
url
=
specfile_url
.
template
.
format
(
package
=
pkg
,
specfile
=
specfile
)
req
=
urllib
.
request
.
Request
(
url
=
url
,
headers
=
headers
)
u
=
urllib
.
request
.
urlopen
(
req
)
return
u
.
read
().
decode
(
"utf-8"
)
def
get_spec_exception
():
req
=
urllib
.
request
.
Request
(
url
=
specfile_exception_url
,
headers
=
headers
)
u
=
urllib
.
request
.
urlopen
(
req
)
exps
=
yaml
.
load
(
u
.
read
().
decode
(
"utf-8"
),
Loader
=
yaml
.
Loader
)
return
exps
def
get_manager_sig
(
pkg
):
sis_load
=
get_sigs
()
for
sig
in
sis_load
[
"sigs"
]:
for
repo
in
sig
[
"repositories"
]:
if
repo
==
"src-openeuler/"
+
pkg
:
return
sig
[
"name"
]
def
get_sig_owners
(
sig_name
):
url
=
sigs_owner_url_template
.
format
(
signame
=
sig_name
)
r
=
get_gitee
(
url
)
owners
=
yaml
.
load
(
r
,
Loader
=
yaml
.
Loader
)
return
owners
[
"maintainers"
]
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"pkg"
,
type
=
str
,
help
=
"The Package to be Queried"
)
args
=
parser
.
parse_args
()
s
=
get_manager_sig
(
args
.
pkg
)
o
=
get_sig_owners
(
s
)
print
(
"SIG Owner:"
)
for
owner
in
o
:
print
(
"
\t
"
+
owner
)
exp
=
get_spec_exception
()
if
args
.
pkg
in
exp
:
dir_name
=
exp
[
args
.
pkg
][
"dir"
]
file_name
=
exp
[
args
.
pkg
][
"file"
]
specurl
=
specfile_url_template
.
format
(
package
=
args
.
pkg
,
specfile
=
dir_name
+
"/"
+
file_name
)
else
:
specurl
=
specfile_url_template
.
format
(
package
=
args
.
pkg
,
specfile
=
args
.
pkg
+
".spec"
)
spec
=
get_gitee
(
specurl
)
in_changelog
=
False
emails
=
set
()
for
line
in
spec
.
splitlines
():
if
line
.
startswith
(
"%changelog"
):
in_changelog
=
True
if
line
.
startswith
(
"*"
)
and
in_changelog
:
m
=
re
.
match
(
".*\d\d\d\d (.*) .*"
,
line
)
if
m
is
None
:
emails
.
add
(
line
)
else
:
n
=
m
[
1
].
split
(
"<"
)
if
len
(
n
)
==
1
:
emails
.
add
(
n
[
0
])
else
:
emails
.
add
(
n
[
0
].
strip
()
+
" <"
+
n
[
1
].
strip
())
print
(
"Package Contributor:"
)
for
email
in
emails
:
print
(
"
\t
"
+
email
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录