cursor = connection.cursor()
# Pattern instance for version numbers
-pattern = re.compile("^(?P<version>v|V{0,1})(\.{0,1})(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)(\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)?$")
+patterns = [
+ re.compile("^(?P<version>v|V{0,1})(\.{0,1})(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)(\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)?$"),
+ re.compile("^(?P<year>[1-9]{1}[0-9]{3})\.(?P<month>[0-9]{2})$")
+]
def remove_version(software: str) -> str:
# NOISY-DEBUG: print(f"DEBUG: software='{software}' - CALLED!")
# NOISY-DEBUG: print(f"DEBUG: Was not able to find common seperator, returning untouched software='{software}'")
return software
- # Run match()
- matches = pattern.match(version)
+ matches = None
+ # NOISY-DEBUG: print(f"DEBUG: Checking {len(patterns)} patterns ...")
+ for pattern in patterns:
+ # Run match()
+ match = pattern.match(version)
+ # NOISY-DEBUG: print(f"DEBUG: match[]={type(match)}")
+ if type(match) is re.Match:
+ break
- # NOISY-DEBUG: print(f"DEBUG: version[{type(version)}]='{version}',matches='{matches}'")
- if type(matches) is not re.Match:
+ # NOISY-DEBUG: print(f"DEBUG: version[{type(version)}]='{version}',match='{match}'")
+ if type(match) is not re.Match:
print(f"WARNING: version='{version}' does not match regex, leaving software='{software}' untouched.")
return software