-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
40 lines (35 loc) · 1.13 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import subprocess
from packaging import version
def unit_incremented(a, b):
"""Check if a is one version larger than b."""
a = version.parse(a)
b = version.parse(b)
if a.pre is not None and b.pre is not None:
if a.pre[0] == b.pre[0]:
return a.pre[1] == b.pre[1] + 1 and a.base_version == b.base_version
else:
return (
a.pre[1] == 0
and a.pre[0] > b.pre[0]
and a.base_version == b.base_version
)
elif a.pre is not None:
return a.base_version > b.base_version and a.pre[1] == 0
elif b.pre is not None:
return a.base_version == b.base_version
else:
return (
a.micro == b.micro + 1
and a.minor == b.minor
and a.major == b.major
or a.micro == 0
and a.minor == b.minor + 1
and a.major == b.major
or a.micro == 0
and a.minor == 0
and a.major == b.major + 1
)
def run(*args):
return subprocess.run(
args, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
).stdout