Skip to content

Commit a9442b5

Browse files
committed
[ModelicaSystem] update handling of xml_file
1 parent abcae09 commit a9442b5

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
@@ -480,8 +480,10 @@ def buildModel(self, variableFilter: Optional[str] = None):
480480
buildModelResult = self._requestApi("buildModel", self._model_name, properties=varFilter)
481481
logger.debug("OM model build result: %s", buildModelResult)
482482

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

486488
def sendExpression(self, expr: str, parsed: bool = True):
487489
try:
@@ -507,11 +509,11 @@ def _requestApi(self, apiName, entity=None, properties=None): # 2
507509

508510
return self.sendExpression(exp)
509511

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

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

0 commit comments

Comments
 (0)