More robust parsing of version numbers.

pull/44/head
Rune B. Broberg 2019-10-13 00:15:04 +02:00
rodzic a50e07fd39
commit 7ffcf93b75
1 zmienionych plików z 2 dodań i 1 usunięć

Wyświetl plik

@ -259,12 +259,13 @@ class Version:
def __init__(self, version_string):
self.version_string = version_string
results = re.match(r"(.*\D+)?(\d+)\.(\d+)\.(\d+)(.*)", version_string)
results = re.match(r"(.*\s+)?(\d+)\.(\d+)\.(\d+)(.*)", version_string)
if results:
self.major = int(results.group(2))
self.minor = int(results.group(3))
self.revision = int(results.group(4))
self.note = results.group(5)
print("Parsed version as %d.%d.%d%s" % (self.major, self.minor, self.revision, self.note))
logger.debug("Parsed version as %d.%d.%d%s", self.major, self.minor, self.revision, self.note)
@staticmethod