|
1
|
|
|
# Licensed to the StackStorm, Inc ('StackStorm') under one or more |
|
2
|
|
|
# contributor license agreements. See the NOTICE file distributed with |
|
3
|
|
|
# this work for additional information regarding copyright ownership. |
|
4
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0 |
|
5
|
|
|
# (the "License"); you may not use this file except in compliance with |
|
6
|
|
|
# the License. You may obtain a copy of the License at |
|
7
|
|
|
# |
|
8
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
|
9
|
|
|
# |
|
10
|
|
|
# Unless required by applicable law or agreed to in writing, software |
|
11
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
|
12
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13
|
|
|
# See the License for the specific language governing permissions and |
|
14
|
|
|
# limitations under the License. |
|
15
|
|
|
|
|
16
|
|
|
import semver |
|
17
|
|
|
|
|
18
|
|
|
__all__ = [ |
|
19
|
|
|
'version_compare', |
|
20
|
|
|
'version_more_than', |
|
21
|
|
|
'version_less_than', |
|
22
|
|
|
'version_equal', |
|
23
|
|
|
'version_match', |
|
24
|
|
|
'version_bump_major', |
|
25
|
|
|
'version_bump_minor' |
|
26
|
|
|
] |
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
def version_compare(value, pattern): |
|
30
|
|
|
return semver.compare(value, pattern) |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
def version_more_than(value, pattern): |
|
34
|
|
|
return semver.compare(value, pattern) == 1 |
|
35
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
def version_less_than(value, pattern): |
|
38
|
|
|
return semver.compare(value, pattern) == -1 |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
def version_equal(value, pattern): |
|
42
|
|
|
return semver.compare(value, pattern) == 0 |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
def version_match(value, pattern): |
|
46
|
|
|
return semver.match(value, pattern) |
|
47
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
def version_bump_major(value): |
|
50
|
|
|
return semver.bump_major(value) |
|
51
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
def version_bump_minor(value): |
|
54
|
|
|
return semver.bump_minor(value) |
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
def version_bump_patch(value): |
|
58
|
|
|
return semver.bump_patch(value) |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
def version_strip_patch(value): |
|
62
|
|
|
return "{major}.{minor}".format(**semver.parse(value)) |
|
63
|
|
|
|