mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-24 12:21:07 +02:00
removed trailing zeros
This commit is contained in:
@ -6,12 +6,22 @@ Script to update VERSION file with semantic versioning if provided as an argumen
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
from packaging.version import Version, InvalidVersion
|
from packaging.version import Version, InvalidVersion
|
||||||
|
|
||||||
|
|
||||||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
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():
|
def get_version():
|
||||||
|
|
||||||
# Check at least one argument is passed
|
# Check at least one argument is passed
|
||||||
@ -21,9 +31,14 @@ def get_version():
|
|||||||
version = sys.argv[1]
|
version = sys.argv[1]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
v = Version(version) # normalizcheck if version follows PEP 440 specification
|
v = Version(version) # normalize check if version follows PEP 440 specification
|
||||||
#replace -
|
|
||||||
return version.replace("-", ".")
|
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:
|
except InvalidVersion as e:
|
||||||
print(f"Invalid version {version}. Version format must follow semantic versioning format of python PEP 440 version identification specification.")
|
print(f"Invalid version {version}. Version format must follow semantic versioning format of python PEP 440 version identification specification.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
Reference in New Issue
Block a user