mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-30 18:50:58 +00:00
parent
16b5bb8810
commit
57cf57b408
@ -49,7 +49,7 @@ def int_to_macaddress(integer):
|
|||||||
|
|
||||||
def parse_version(version):
|
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
|
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
|
continue
|
||||||
try:
|
try:
|
||||||
info = int(info)
|
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:
|
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
|
# We want rc to be at lower level than dev version
|
||||||
if info == 'rc':
|
if info == 'rc':
|
||||||
info = 'c'
|
info = 'c'
|
||||||
version.append(info)
|
version.append(info)
|
||||||
release_type_found = True
|
release_type_found = True
|
||||||
if release_type_found is False:
|
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")
|
version.append("final")
|
||||||
return tuple(version)
|
return tuple(version)
|
||||||
|
@ -34,11 +34,11 @@ def test_int_to_macaddress():
|
|||||||
|
|
||||||
|
|
||||||
def test_parse_version():
|
def test_parse_version():
|
||||||
assert parse_version('1') == (1, 'final')
|
assert parse_version('1') == ('000001', '00000', '000000', 'final')
|
||||||
assert parse_version('1.3') == (1, 3, 'final')
|
assert parse_version('1.3') == ('000001', '000003', '000000', 'final')
|
||||||
assert parse_version('1.3.dev3') == (1, 3, 'dev', 3)
|
assert parse_version('1.3.dev3') == ('000001', '000003', '000000', 'dev', '000003')
|
||||||
assert parse_version('1.3a1') == (1, 3, 'a', 1)
|
assert parse_version('1.3a1') == ('000001', '000003', '000000', 'a', '000001')
|
||||||
assert parse_version('1.3rc1') == (1, 3, 'c', 1)
|
assert parse_version('1.3rc1') == ('000001', '000003', '000000', 'c', '000001')
|
||||||
|
|
||||||
assert parse_version('1.2.3') > parse_version('1.2.2')
|
assert parse_version('1.2.3') > parse_version('1.2.2')
|
||||||
assert parse_version('1.3') > parse_version('1.2.2')
|
assert parse_version('1.3') > parse_version('1.2.2')
|
||||||
@ -46,3 +46,4 @@ def test_parse_version():
|
|||||||
assert parse_version('1.3') > parse_version('1.3rc1')
|
assert parse_version('1.3') > parse_version('1.3rc1')
|
||||||
assert parse_version('1.3rc1') > parse_version('1.3alpha3')
|
assert parse_version('1.3rc1') > parse_version('1.3alpha3')
|
||||||
assert parse_version('1.3dev1') > parse_version('1.3rc1')
|
assert parse_version('1.3dev1') > parse_version('1.3rc1')
|
||||||
|
assert parse_version('1.2.3') > parse_version('1.2')
|
||||||
|
Loading…
Reference in New Issue
Block a user