Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
openEuler-Advisor
提交
1f32a6ba
O
openEuler-Advisor
项目概览
openeuler
/
openEuler-Advisor
通知
30
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,体验更适合开发者的 AI 搜索 >>
提交
1f32a6ba
编写于
7月 10, 2020
作者:
L
licihua
提交者:
Shinwell_Hu
7月 10, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
!16 [version-recommend]修改VersionType 函数名 _max 为 _compare,提供对外 compare 接口
* 修改VersionType 函数名 _max 为 _compare,提供对外 compare 接口
上级
ba07e750
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
18 deletion
+31
-18
advisors/simple-update-robot.py
advisors/simple-update-robot.py
+1
-1
advisors/version_recommend.py
advisors/version_recommend.py
+30
-17
未找到文件。
advisors/simple-update-robot.py
浏览文件 @
1f32a6ba
...
...
@@ -133,7 +133,7 @@ if __name__ == "__main__":
print
(
"I'm too naive to handle complicated package."
)
print
(
"This package has multiple in-house patches."
)
sys
.
exit
(
1
)
if
(
my_version
.
_max
(
args
.
new_version
,
cur_ver
)
==
1
):
if
(
my_version
.
compare
(
args
.
new_version
,
cur_ver
)
==
1
):
create_spec
(
args
.
pkg
,
spec_string
,
cur_ver
,
args
.
new_version
)
else
:
print
(
"Please check version of {pkg} will upgrade to, it's current version is {version}."
.
format
(
...
...
advisors/version_recommend.py
浏览文件 @
1f32a6ba
...
...
@@ -61,7 +61,20 @@ class VersionType(object):
_
=
version_entry
,
pkg_type
return
current_version
def
_max
(
self
,
z1
,
z2
):
def
compare
(
self
,
z1
,
z2
):
"""
Get the max version.
:param z1: The first version
:param z2: The second version
:returns 1: z1 great then z2
:return -1: z2 great then z1
:return 0: z1 equal then z2
:raises: None
"""
return
self
.
_compare
(
self
,
z1
,
z2
)
def
_compare
(
self
,
z1
,
z2
):
"""
Get the max version.
...
...
@@ -176,7 +189,7 @@ class VersionTypeXYZW(VersionType):
if
len
(
version
)
<=
3
:
continue
if
self
.
_
max
(
version
[
3
],
w
)
>
0
:
if
self
.
_
compare
(
version
[
3
],
w
)
>
0
:
w
=
version
[
3
]
xyz
.
append
(
w
)
...
...
@@ -197,7 +210,7 @@ class VersionTypeXYZW(VersionType):
version_list
.
append
(
re
.
split
(
r
'[._-]'
,
version
))
# 将 version 拆分为列表,方便后续比较
x
=
'0'
for
version
in
version_list
:
# 第一轮比较取出最大的第一位
if
self
.
_
max
(
x
,
version
[
0
])
<
0
:
if
self
.
_
compare
(
x
,
version
[
0
])
<
0
:
x
=
version
[
0
]
version_candidate
=
[]
...
...
@@ -213,7 +226,7 @@ class VersionTypeXYZW(VersionType):
for
version
in
version_list
:
# 第二轮比较取出最大的第二位
if
len
(
version
)
<=
1
:
# 过滤仅一位的版本号
continue
if
self
.
_
max
(
y
,
version
[
1
])
<
0
:
if
self
.
_
compare
(
y
,
version
[
1
])
<
0
:
y
=
version
[
1
]
version_candidate
.
clear
()
...
...
@@ -229,7 +242,7 @@ class VersionTypeXYZW(VersionType):
for
version
in
version_list
:
# 第三轮比较取出最大的第三位
if
len
(
version
)
<=
2
:
# 过滤仅二位的版本号
continue
if
self
.
_
max
(
z
,
version
[
2
])
<
0
:
if
self
.
_
compare
(
z
,
version
[
2
])
<
0
:
z
=
version
[
2
]
version_candidate
.
clear
()
...
...
@@ -247,7 +260,7 @@ class VersionTypeXYZW(VersionType):
for
version
in
version_list
:
# 最后一位最大版本必须惟一,直接返回结果
if
len
(
version
)
<=
3
:
# 过滤仅三位的版本号
continue
if
self
.
_
max
(
w
,
version
[
3
])
<
0
:
if
self
.
_
compare
(
w
,
version
[
3
])
<
0
:
w
=
version
[
3
]
for
version
in
version_list
:
# 最后一位最大版本必须惟一,直接返回结果
...
...
@@ -323,7 +336,7 @@ class VersionTypeXYZ(VersionType):
if
len
(
version
)
<=
2
:
continue
if
self
.
_
max
(
version
[
2
],
z
)
>
0
:
if
self
.
_
compare
(
version
[
2
],
z
)
>
0
:
z
=
version
[
2
]
xy
.
append
(
z
)
...
...
@@ -344,7 +357,7 @@ class VersionTypeXYZ(VersionType):
version_list
.
append
(
re
.
split
(
r
'[._-]'
,
version
))
# 将 version 拆分为列表,方便后续比较
x
=
'0'
for
version
in
version_list
:
# 第一轮比较取出最大的第一位
if
self
.
_
max
(
x
,
version
[
0
])
<
0
:
if
self
.
_
compare
(
x
,
version
[
0
])
<
0
:
x
=
version
[
0
]
version_candidate
=
[]
...
...
@@ -360,7 +373,7 @@ class VersionTypeXYZ(VersionType):
for
version
in
version_list
:
# 第二轮比较取出最大的第二位
if
len
(
version
)
<=
1
:
# 过滤仅一位的版本号
continue
if
self
.
_
max
(
y
,
version
[
1
])
<
0
:
if
self
.
_
compare
(
y
,
version
[
1
])
<
0
:
y
=
version
[
1
]
version_candidate
.
clear
()
...
...
@@ -376,7 +389,7 @@ class VersionTypeXYZ(VersionType):
for
version
in
version_list
:
# 第三轮比较取出最大的第三位
if
len
(
version
)
<=
2
:
# 过滤仅二位的版本号
continue
if
self
.
_
max
(
z
,
version
[
2
])
<
0
:
if
self
.
_
compare
(
z
,
version
[
2
])
<
0
:
z
=
version
[
2
]
for
version
in
version_list
:
# 最后一位最大版本必须惟一,直接返回结果
...
...
@@ -447,7 +460,7 @@ class VersionTypeXY(VersionType):
version_list
.
append
(
re
.
split
(
r
'[._-]'
,
version
))
# 将 version 拆分为列表,方便后续比较
x
=
'0'
for
version
in
version_list
:
# 第一轮比较取出最大的第一位
if
self
.
_
max
(
x
,
version
[
0
])
<
0
:
if
self
.
_
compare
(
x
,
version
[
0
])
<
0
:
x
=
version
[
0
]
version_candidate
=
[]
...
...
@@ -463,7 +476,7 @@ class VersionTypeXY(VersionType):
for
version
in
version_list
:
# 第二轮比较取出最大的第二位
if
len
(
version
)
<=
1
:
# 过滤仅一位的版本号
continue
if
self
.
_
max
(
y
,
version
[
1
])
<
0
:
if
self
.
_
compare
(
y
,
version
[
1
])
<
0
:
y
=
version
[
1
]
version_candidate
.
clear
()
...
...
@@ -481,7 +494,7 @@ class VersionTypeXY(VersionType):
for
version
in
version_list
:
# 第三轮比较取出最大的第三位
if
len
(
version
)
<=
2
:
# 过滤仅二位的版本号
continue
if
self
.
_
max
(
z
,
version
[
2
])
<
0
:
if
self
.
_
compare
(
z
,
version
[
2
])
<
0
:
z
=
version
[
2
]
for
version
in
version_list
:
# 最后一位最大版本必须惟一,直接返回结果
...
...
@@ -518,7 +531,7 @@ class VersionTypeXY(VersionType):
if
len
(
version
)
<=
1
:
continue
if
self
.
_
max
(
version
[
1
],
y
)
>
0
:
if
self
.
_
compare
(
version
[
1
],
y
)
>
0
:
y
=
version
[
1
]
x
.
append
(
y
)
return
'.'
.
join
(
x
)
...
...
@@ -559,7 +572,7 @@ class VersionTypeX(VersionType):
version_list
.
append
(
re
.
split
(
r
'[._-]'
,
version
))
# 将 version 拆分为列表,方便后续比较
x
=
'0'
for
version
in
version_list
:
# 第一轮比较取出最大的第一位
if
self
.
_
max
(
x
,
version
[
0
])
<
0
:
if
self
.
_
compare
(
x
,
version
[
0
])
<
0
:
x
=
version
[
0
]
version_candidate
=
[]
...
...
@@ -575,7 +588,7 @@ class VersionTypeX(VersionType):
for
version
in
version_list
:
# 第二轮比较取出最大的第二位
if
len
(
version
)
<=
1
:
# 过滤仅一位的版本号
continue
if
self
.
_
max
(
y
,
version
[
1
])
<
0
:
if
self
.
_
compare
(
y
,
version
[
1
])
<
0
:
y
=
version
[
1
]
x
.
append
(
y
)
...
...
@@ -607,7 +620,7 @@ class VersionTypeX(VersionType):
if
len
(
version
)
<=
1
:
continue
if
self
.
_
max
(
version
[
1
],
y
)
>
0
:
if
self
.
_
compare
(
version
[
1
],
y
)
>
0
:
y
=
version
[
1
]
x
.
append
(
y
)
return
'.'
.
join
(
x
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录