Skip to content

Commit aba889f

Browse files
committed
version tuple
1 parent a949af2 commit aba889f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

OMPython/ModelicaSystem.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,12 @@ def getOptimizationOptions(
10211021

10221022
raise ModelicaSystemError("Unhandled input for getOptimizationOptions()")
10231023

1024+
def parse_om_version(version: str) -> tuple[int, int, int]:
1025+
match = re.search(r"v?(\d+)\.(\d+)\.(\d+)", version)
1026+
if not match:
1027+
raise ValueError(f"Version not found in: {version}")
1028+
return tuple(map(int, match.groups()))
1029+
10241030
def simulate_cmd(
10251031
self,
10261032
result_file: OMCPath,
@@ -1072,23 +1078,17 @@ def simulate_cmd(
10721078
# see https://github.com/OpenModelica/OpenModelica/pull/14813
10731079
version = self._session.sendExpression("getVersion()", parsed=True)
10741080
print(f"OpenModelica version string: {version}")
1075-
1076-
m = re.search(r"v(\d+)\.(\d+)\.(\d+)", version)
1077-
if not m:
1078-
raise ValueError("Version not found")
1079-
1080-
major, minor, patch = map(int, m.groups())
1081-
1081+
major, minor, patch = parse_om_version(version)
10821082
if (major, minor, patch) > (1, 25, 0):
1083-
print("Version > 1.27.0")
1083+
print("Version > 1.25.0")
10841084
for key, opt_value in self._simulate_options_override.items():
10851085
om_cmd.arg_set(key=key, val=str(opt_value))
10861086
override_content = (
10871087
"\n".join([f"{key}={value}" for key, value in self._override_variables.items()])
10881088
+ "\n"
10891089
)
10901090
else:
1091-
print("Version < 1.27.0")
1091+
print("Version < 1.25.0")
10921092
override_content = (
10931093
"\n".join([f"{key}={value}" for key, value in self._override_variables.items()])
10941094
+ "\n".join([f"{key}={value}" for key, value in self._simulate_options_override.items()])

0 commit comments

Comments
 (0)