]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 27 May 2023 07:35:08 +0000 (09:35 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 27 May 2023 07:35:08 +0000 (09:35 +0200)
- added regex for hexa-decimal "version numbers"
- removed some extras from (software) generator before checking it against a regex

fba.py

diff --git a/fba.py b/fba.py
index 3ac23c37b64f84bbf0b62080b1ce6cc6ba7bff0f..1bddacd8d273a7cf5f343cbbe2445c1d94a66e9c 100644 (file)
--- a/fba.py
+++ b/fba.py
@@ -96,7 +96,9 @@ patterns = [
     # non-sematic, e.g. 1.2.3.4
     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<subpatch>0|[1-9]\d*))?)$"),
     # non-sematic, e.g. 2023-05
-    re.compile("^(?P<year>[1-9]{1}[0-9]{3})\.(?P<month>[0-9]{2})$")
+    re.compile("^(?P<year>[1-9]{1}[0-9]{3})\.(?P<month>[0-9]{2})(-dev){0,1}$"),
+    # non-semantic, e.g. abcdef0
+    re.compile("^[a-f0-9]{7}$"),
 ]
 
 def remove_version(software: str) -> str:
@@ -105,6 +107,14 @@ def remove_version(software: str) -> str:
         print(f"WARNING: software='{software}' does not contain a version number.")
         return software
 
+    if ";" in software:
+        software = software.split(";")[0]
+    elif "," in software:
+        software = software.split(",")[0]
+    elif " - " in software:
+        software = software.split(" - ")[0]
+
+    # NOISY-DEBUG: print(f"DEBUG: software='{software}'")
     version = None
     if " " in software:
         version = software.split(" ")[-1]
@@ -117,6 +127,7 @@ def remove_version(software: str) -> str:
         return software
 
     matches = None
+    match = None
     # NOISY-DEBUG: print(f"DEBUG: Checking {len(patterns)} patterns ...")
     for pattern in patterns:
         # Run match()