From 1d85dcbea325f11f29b8be8555df85808234eb51 Mon Sep 17 00:00:00 2001 From: syntron Date: Tue, 2 Dec 2025 21:36:38 +0100 Subject: [PATCH 1/5] [OMParser] cleanup usage of Dict --- OMPython/OMParser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OMPython/OMParser.py b/OMPython/OMParser.py index 8b3474066..3ccda1099 100644 --- a/OMPython/OMParser.py +++ b/OMPython/OMParser.py @@ -33,9 +33,9 @@ """ import sys -from typing import Dict, Any +from typing import Any -result: Dict[str, Any] = dict() +result: dict[str, Any] = {} inner_sets = [] next_set_list = [] From a8296d32ae22e8e4899c46050867b76315ff136c Mon Sep 17 00:00:00 2001 From: syntron Date: Sat, 7 Feb 2026 15:26:36 +0100 Subject: [PATCH 2/5] [OMParser] remove import sys --- OMPython/OMParser.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/OMPython/OMParser.py b/OMPython/OMParser.py index 3ccda1099..f7b1ff689 100644 --- a/OMPython/OMParser.py +++ b/OMPython/OMParser.py @@ -32,7 +32,6 @@ Version: 1.0 """ -import sys from typing import Any result: dict[str, Any] = {} @@ -566,8 +565,8 @@ def skip_all_inner_sets(position): break pos += 1 if count != 0: - print("\nParser Error: Are you missing one or more '}'s? \n") - sys.exit(1) + raise ValueError("Parser Error: Are you missing one or more '}}'s in string? " + f"(string value: {repr(string)}") if max_count >= 2: while position < end_of_main_set: @@ -745,8 +744,7 @@ def skip_all_inner_sets(position): else: return current_set, next_set[0] else: - print("\nThe following String has no {}s to proceed\n") - print(string) + raise ValueError(f"The following String has no {{}}s to proceed: {repr(string)}!") # End of get_the_string() From ef6a38d1ad30cefc8f25a93961f4a2343308a4c3 Mon Sep 17 00:00:00 2001 From: syntron Date: Tue, 2 Dec 2025 21:44:17 +0100 Subject: [PATCH 3/5] [OMParser] basic pylint fixes --- OMPython/OMParser.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/OMPython/OMParser.py b/OMPython/OMParser.py index f7b1ff689..39168e302 100644 --- a/OMPython/OMParser.py +++ b/OMPython/OMParser.py @@ -46,10 +46,9 @@ def bool_from_string(string): """Attempt conversion of string to a boolean """ if string in {'true', 'True', 'TRUE'}: return True - elif string in {'false', 'False', 'FALSE'}: + if string in {'false', 'False', 'FALSE'}: return False - else: - raise ValueError + raise ValueError def typeCheck(string): @@ -66,9 +65,7 @@ def typeCheck(string): return t(string) except ValueError: continue - else: - print("String contains un-handled datatype") - return string + raise ValueError(f"String contains un-handled datatype: {repr(string)}!") def make_values(strings, name): @@ -186,12 +183,12 @@ def delete_elements(strings): char = strings[pos] if char == "": break - elif char == ",": + if char == ",": break - elif char == " ": + if char == " ": pos = pos + 1 break - elif char == "{": + if char == "{": break pos = pos - 1 delStr = strings[pos: strings.rfind(")")] @@ -682,15 +679,14 @@ def skip_all_inner_sets(position): position += 1 else: next_set[0] = "" - return (len(string) - 1) + return len(string) - 1 max_of_sets = max(last_set, last_subset) max_of_main_set = max(max_of_sets, last_subset) if max_of_main_set != 0: return max_of_main_set - else: - return (len(string) - 1) + return len(string) - 1 # Main entry of get_the_string() index = 0 @@ -833,7 +829,7 @@ def check_for_values(string): if "record SimulationResult" in string: formatSimRes(string) return result - elif "record " in string: + if "record " in string: formatRecords(string) return result @@ -841,7 +837,7 @@ def check_for_values(string): if not isinstance(string, str): return string - elif string.find("{") == -1: + if string.find("{") == -1: return string current_set, next_set = get_the_set(string) From 0d436c8c467af3e91890ccb3fdb5598130e95685 Mon Sep 17 00:00:00 2001 From: syntron Date: Tue, 2 Dec 2025 21:44:59 +0100 Subject: [PATCH 4/5] [OMParser] optimise code in make_values() --- OMPython/OMParser.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/OMPython/OMParser.py b/OMPython/OMParser.py index 39168e302..73f38d7b7 100644 --- a/OMPython/OMParser.py +++ b/OMPython/OMParser.py @@ -157,14 +157,9 @@ def make_values(strings, name): varValue = (varValue.replace('{', '').strip()).replace('}', '').strip() multiple_values = varValue.split(",") - for n in range(len(multiple_values)): - each_v = multiple_values[n] - multiple_values.pop(n) - each_v = typeCheck(each_v) - multiple_values.append(each_v) - if len(multiple_values) != 0: - result[main_set_name]['Elements'][name]['Properties']['Results'][varName] = multiple_values + multiple_values_type_checked = [typeCheck(val) for val in multiple_values] + result[main_set_name]['Elements'][name]['Properties']['Results'][varName] = multiple_values_type_checked elif varName != "" and varValue != "": result[main_set_name]['Elements'][name]['Properties']['Results'][varName] = varValue else: From 8f6ebd7ded57f2e0bbf84d98c6f3848967d9b24c Mon Sep 17 00:00:00 2001 From: syntron Date: Sun, 8 Feb 2026 16:31:34 +0100 Subject: [PATCH 5/5] [OMParser] remove unused variables --- OMPython/OMParser.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/OMPython/OMParser.py b/OMPython/OMParser.py index 73f38d7b7..a82a9ca06 100644 --- a/OMPython/OMParser.py +++ b/OMPython/OMParser.py @@ -36,8 +36,6 @@ result: dict[str, Any] = {} -inner_sets = [] -next_set_list = [] next_set = [] next_set.append('')