Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
openEuler-Advisor
提交
dbd244da
O
openEuler-Advisor
项目概览
openeuler
/
openEuler-Advisor
通知
47
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看板
提交
dbd244da
编写于
8月 22, 2020
作者:
S
Shinwell Hu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
import psrtool
上级
255af540
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
81 addition
and
0 deletion
+81
-0
advisors/psrtool.py
advisors/psrtool.py
+81
-0
未找到文件。
advisors/psrtool.py
0 → 100755
浏览文件 @
dbd244da
#!/usr/bin/python3
#******************************************************************************
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
# licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
# http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
#
# This is a helper script provides a way to query or list packages in specific SIG.
# This script was inspired by previous work from @love_hangzhou
# ******************************************************************************/
import
yaml
,
argparse
,
re
,
os
def
list_packages
(
sigs
,
sig_name
):
for
sig
in
sigs
:
if
sig
[
'name'
].
lower
()
==
sig_name
.
lower
():
return
sig
[
'repositories'
]
def
list_sigs
(
sigs
):
result
=
[]
for
sig
in
sigs
:
result
.
append
(
sig
[
'name'
])
return
result
def
package_to_sigs
(
sigs
,
pkg_names
):
result
=
{}
for
pkg
in
pkg_names
:
for
sig
in
sigs
:
repos
=
sig
[
'repositories'
]
for
repo
in
repos
:
searchObj
=
re
.
search
(
pkg
.
lower
(),
repo
.
lower
(),
0
)
if
searchObj
:
result
[
repo
]
=
sig
[
'name'
]
return
result
def
print_list
(
l
):
for
i
in
l
:
print
(
i
)
def
print_dict
(
d
):
for
k
in
d
.
keys
():
print
(
k
+
": "
+
d
[
k
])
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
()
group
=
parser
.
add_mutually_exclusive_group
(
required
=
True
)
group
.
add_argument
(
"-l"
,
"--list"
,
default
=
False
,
nargs
=
'?'
,
help
=
"List packages managed by the specific SIG, or list all SIGs instead"
)
group
.
add_argument
(
"-q"
,
"--query_packages"
,
default
=
False
,
nargs
=
'+'
,
help
=
"Query which SIG manage the specific package"
)
parser
.
add_argument
(
"-f"
,
"--yaml"
,
default
=
"sig/sigs.yaml"
,
help
=
"Local path of sigs.yaml file"
)
args
=
parser
.
parse_args
()
try
:
with
open
(
args
.
yaml
,
'r'
)
as
f
:
sigs
=
yaml
.
load
(
f
,
Loader
=
yaml
.
Loader
)[
'sigs'
]
except
:
print
(
"Failed to load information from %s"
%
args
.
yaml
)
parser
.
print_help
()
exit
(
1
)
if
args
.
list
:
print_list
(
list_packages
(
sigs
,
args
.
list
))
elif
args
.
list
is
None
:
print_list
(
list_sigs
(
sigs
))
elif
args
.
query_packages
:
print_dict
(
package_to_sigs
(
sigs
,
args
.
query_packages
))
else
:
pass
exit
(
0
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录