Skip to content

Commit f10e4e0

Browse files
committed
[ModelicaSystem] update handling of xml_file
1 parent 3e9c55b commit f10e4e0

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,10 @@ def buildModel(self, variableFilter: Optional[str] = None):
481481
buildModelResult = self._requestApi("buildModel", self._model_name, properties=varFilter)
482482
logger.debug("OM model build result: %s", buildModelResult)
483483

484-
self._xml_file = pathlib.Path(buildModelResult[0]).parent / buildModelResult[1]
485-
self._xmlparse()
484+
xml_file = pathlib.Path(buildModelResult[0]).parent / buildModelResult[1]
485+
self._xmlparse(xml_file=xml_file)
486+
# TODO: remove _xml_file?!
487+
self._xml_file = xml_file
486488

487489
def sendExpression(self, expr: str, parsed: bool = True):
488490
try:
@@ -508,11 +510,11 @@ def _requestApi(self, apiName, entity=None, properties=None): # 2
508510

509511
return self.sendExpression(exp)
510512

511-
def _xmlparse(self):
512-
if not self._xml_file.is_file():
513-
raise ModelicaSystemError(f"XML file not generated: {self._xml_file}")
513+
def _xmlparse(self, xml_file: pathlib.Path):
514+
if not xml_file.is_file():
515+
raise ModelicaSystemError(f"XML file not generated: {xml_file}")
514516

515-
tree = ET.parse(self._xml_file)
517+
tree = ET.parse(xml_file)
516518
rootCQ = tree.getroot()
517519
for attr in rootCQ.iter('DefaultExperiment'):
518520
for key in ("startTime", "stopTime", "stepSize", "tolerance",

0 commit comments

Comments
 (0)