From d67637477d76fc9276ad6c33cedf3e22a1f9e268 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 27 May 2023 09:44:48 +0200 Subject: [PATCH] Continued: - better only temporary split semicolon off, not from input variable --- fba.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fba.py b/fba.py index 1bddacd..b5d536e 100644 --- a/fba.py +++ b/fba.py @@ -107,21 +107,22 @@ def remove_version(software: str) -> str: print(f"WARNING: software='{software}' does not contain a version number.") return software + temp = software if ";" in software: - software = software.split(";")[0] + temp = software.split(";")[0] elif "," in software: - software = software.split(",")[0] + temp = software.split(",")[0] elif " - " in software: - software = software.split(" - ")[0] + temp = software.split(" - ")[0] # NOISY-DEBUG: print(f"DEBUG: software='{software}'") version = None if " " in software: - version = software.split(" ")[-1] + version = temp.split(" ")[-1] elif "/" in software: - version = software.split("/")[-1] + version = temp.split("/")[-1] elif "-" in software: - version = software.split("-")[-1] + version = temp.split("-")[-1] else: # NOISY-DEBUG: print(f"DEBUG: Was not able to find common seperator, returning untouched software='{software}'") return software @@ -143,10 +144,10 @@ def remove_version(software: str) -> str: return software # NOISY-DEBUG: print(f"DEBUG: Found valid version number: '{version}', removing it ...") - end = len(software) - len(version) - 1 + end = len(temp) - len(version) - 1 # NOISY-DEBUG: print(f"DEBUG: end[{type(end)}]={end}") - software = software[0:end].strip() + software = temp[0:end].strip() if " version" in software: # NOISY-DEBUG: print(f"DEBUG: software='{software}' contains word ' version'") software = strip_until(software, " version") -- 2.39.5