removed trailing zeros
Some checks failed
Build on RHEL9 / build (push) Successful in 2m23s
Build on RHEL8 / build (push) Failing after 2m37s

This commit is contained in:
mazzol_a
2025-05-06 08:57:53 +02:00
parent 81f2a737e9
commit c8acde6a27

View File

@ -6,12 +6,22 @@ Script to update VERSION file with semantic versioning if provided as an argumen
import sys
import os
import re
from packaging.version import Version, InvalidVersion
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
def is_integer(value):
try:
int(value)
except ValueError:
return False
else:
return True
def get_version():
# Check at least one argument is passed
@ -21,9 +31,14 @@ def get_version():
version = sys.argv[1]
try:
v = Version(version) # normalizcheck if version follows PEP 440 specification
#replace -
return version.replace("-", ".")
v = Version(version) # normalize check if version follows PEP 440 specification
version_normalized = version.replace("-", ".")
version_normalized = re.sub(r'0*(\d+)', lambda m : str(int(m.group(0))), version_normalized) #remove leading zeros
return version_normalized
except InvalidVersion as e:
print(f"Invalid version {version}. Version format must follow semantic versioning format of python PEP 440 version identification specification.")
sys.exit(1)