Skip to content

Commit a33dc68

Browse files
committed
[ModelicaSystem] create override file using pathlib.Path.write_text()
background: open() is not available if OMCPath is used
1 parent 4d0a4bc commit a33dc68

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

OMPython/ModelicaSystem.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -958,11 +958,9 @@ def simulate_cmd(
958958
if self._override_variables or self._simulate_options_override:
959959
tmpdict = self._override_variables.copy()
960960
tmpdict.update(self._simulate_options_override)
961-
# write to override file
962-
with open(file=overrideFile, mode="w", encoding="utf-8") as fh:
963-
for key, value in tmpdict.items():
964-
fh.write(f"{key}={value}\n")
965961

962+
override_content = "\n".join([f"{key}={value}" for key, value in tmpdict.items()]) + "\n"
963+
overrideFile.write_text(override_content)
966964
om_cmd.arg_set(key="overrideFile", val=overrideFile.as_posix())
967965

968966
if self._has_inputs: # if model has input quantities

0 commit comments

Comments
 (0)