Skip to content

Commit ae4bf2e

Browse files
reintroduce missing script (#249)
1 parent 1b85dd1 commit ae4bf2e

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

scripts/is_semantic_version.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import typer
2+
from semver.version import Version as V
3+
4+
5+
def main(version_string: str, raise_result: bool = True):
6+
"""
7+
Check if a string v is a "pure" semantic version. I.e. v=a.b.c
8+
for positive integers a, b and c. We don't allow prerelease info
9+
or dev info here.
10+
"""
11+
result: bool = V.is_valid(version_string)
12+
if result:
13+
v: V = V.parse(version_string)
14+
result = v == V(v.major, v.minor, v.patch)
15+
if raise_result:
16+
raise typer.Exit(code=0 if result else 1)
17+
print(result)
18+
19+
20+
if __name__ == "__main__":
21+
typer.run(main)

0 commit comments

Comments
 (0)