Skip to content

Commit

Permalink
Merge pull request #34 from konstin/versionparser
Browse files Browse the repository at this point in the history
Bug fixes for Versionparser
  • Loading branch information
Nudin authored Jul 3, 2018
2 parents ba6cad8 + 2117155 commit bfdbf72
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions versionhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def extract_version(
"""
# Remove a prefix of the name of the program if existent
if name:
namere = re.compile(r"^" + re.escape(name) + r"[ -_]", re.IGNORECASE)
namere = re.compile(r"^" + re.escape(name) + r"[ _-]", re.IGNORECASE)
match = namere.match(string)
if match:
string = string[match.end() :]
Expand All @@ -35,7 +35,7 @@ def extract_version(

stable = re.compile(r"(\s|^|v)(\d{1,3}(\.\d{1,3})+(-\d\d?|[a-z])?)(\s|$)", re.IGNORECASE)
pre = re.compile(
r"(\s|^|v)((\d{1,3}(\.\d{1,3})+)[.-]?(alpha|beta|pre|rc|b|preview)[.-]?\d*)(\s|$)",
r"(\s|^|v)((\d{1,3}(\.\d{1,3})+)[._-]?(alpha|beta|pre|rc|b|preview)[._-]?\d*)(\s|$)",
re.IGNORECASE,
)
explicitstable = re.compile(
Expand Down
3 changes: 3 additions & 0 deletions versionhandler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def test_unstable():
assert extract_version("1.3b1") == ("beta", "1.3b1")
assert extract_version("Picard 2.0.0beta3") == ("beta", "2.0.0beta3")
assert extract_version("v1.0.0-beta3") == ("beta", "1.0.0-beta3")
assert extract_version("9.3.2_RC1") == ("rc", "9.3.2_RC1")
assert extract_version("v2.1-rc1") == ("rc", "2.1-rc1")


def test_invalid():
Expand All @@ -54,3 +56,4 @@ def test_invalid():
assert extract_version("foo #871") is None
assert extract_version("RC1") is None
assert extract_version("1234567") is None
assert extract_version("mame0199", "mame") is None

0 comments on commit bfdbf72

Please sign in to comment.