Skip to content

Commit bbd8740

Browse files
committed
[ModelicaSystem] simplify _set_method_helper()
1 parent 2fc67b9 commit bbd8740

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,24 +1200,24 @@ def _set_method_helper(
12001200

12011201
inputdata_status: dict[str, bool] = {}
12021202
for key, val in inputdata.items():
1203-
status = False
1204-
if key in classdata:
1205-
if datatype == "parameter" and not self.isParameterChangeable(key):
1206-
logger.debug(f"It is not possible to set the parameter {repr(key)}. It seems to be "
1207-
"structural, final, protected, evaluated or has a non-constant binding. "
1208-
"Use sendExpression(...) and rebuild the model using buildModel() API; example: "
1209-
"sendExpression(\"setParameterValue("
1210-
f"{self.modelName}, {key}, {val if val is not None else '<?value?>'}"
1211-
")\") ")
1212-
else:
1213-
classdata[key] = val
1214-
if overwritedata is not None:
1215-
overwritedata[key] = val
1216-
status = True
1217-
else:
1203+
if key not in classdata:
12181204
raise ModelicaSystemError("Unhandled case in setMethodHelper.apply_single() - "
12191205
f"{repr(key)} is not a {repr(datatype)} variable")
12201206

1207+
status = False
1208+
if datatype == "parameter" and not self.isParameterChangeable(key):
1209+
logger.debug(f"It is not possible to set the parameter {repr(key)}. It seems to be "
1210+
"structural, final, protected, evaluated or has a non-constant binding. "
1211+
"Use sendExpression(...) and rebuild the model using buildModel() API; example: "
1212+
"sendExpression(\"setParameterValue("
1213+
f"{self.modelName}, {key}, {val if val is not None else '<?value?>'}"
1214+
")\") ")
1215+
else:
1216+
classdata[key] = val
1217+
if overwritedata is not None:
1218+
overwritedata[key] = val
1219+
status = True
1220+
12211221
inputdata_status[key] = status
12221222

12231223
return all(inputdata_status.values())

0 commit comments

Comments
 (0)