mirror of
https://github.com/fergalmoran/picard.git
synced 2026-01-06 08:34:01 +00:00
Make version_from_string() more tolerant
This commit is contained in:
@@ -48,7 +48,7 @@ def version_to_string(version, short=False):
|
||||
|
||||
|
||||
def version_from_string(version_str):
|
||||
g = re.match(r"^(\d+).(\d+).(\d+)(dev|final)(\d+)$", version_str).groups()
|
||||
g = re.match(r"^(\d+)[._](\d+)[._](\d+)[._]?(dev|final)[._]?(\d+)$", version_str).groups()
|
||||
return (int(g[0]), int(g[1]), int(g[2]), g[3], int(g[4]))
|
||||
|
||||
|
||||
|
||||
@@ -54,3 +54,7 @@ class VersionsTest(unittest.TestCase):
|
||||
def test_version_conv_11(self):
|
||||
l, s = ('1', '1', '0', 'dev', '0'), '1.1.0dev0'
|
||||
self.assertEqual(version_to_string(l), s)
|
||||
|
||||
def test_version_conv_12(self):
|
||||
l, s = (1, 1, 0, 'dev', 0), '1_1_0_dev_0'
|
||||
self.assertEqual(l, version_from_string(s))
|
||||
|
||||
Reference in New Issue
Block a user