mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Merge pull request #516 from GNS3/improve_parse_version
Improve parse_version
This commit is contained in:
commit
41f02dad54
2 files changed
+20
-7
No files matched your search
@@ -49,7 +49,7 @@ def int_to_macaddress(integer):
|
||||
|
||||
def parse_version(version):
|
||||
"""
|
||||
Return a comparable tuple from a version string.
|
||||
Return a comparable tuple from a version string. We try to force tuple to semver with version like 1.2.0
|
||||
|
||||
Replace pkg_resources.parse_version which now display a warning when use for comparing version with tuple
|
||||
|
||||
@@ -64,13 +64,25 @@ def parse_version(version):
|
||||
continue
|
||||
try:
|
||||
info = int(info)
|
||||
version.append(info)
|
||||
# We pad with zero to compare only on string
|
||||
# This avoid issue when comparing version with different length
|
||||
version.append("%06d" % (info,))
|
||||
except ValueError:
|
||||
# Force to a version with three number
|
||||
if len(version) == 1:
|
||||
version.append("00000")
|
||||
if len(version) == 2:
|
||||
version.append("000000")
|
||||
# We want rc to be at lower level than dev version
|
||||
if info == 'rc':
|
||||
info = 'c'
|
||||
version.append(info)
|
||||
release_type_found = True
|
||||
if release_type_found is False:
|
||||
# Force to a version with three number
|
||||
if len(version) == 1:
|
||||
version.append("00000")
|
||||
if len(version) == 2:
|
||||
version.append("000000")
|
||||
version.append("final")
|
||||
return tuple(version)
|
||||
Reference in new issue
Block a user