@@ -1580,7 +1580,7 @@ def convertMo2Fmu(
15801580 fmuType : str = "me_cs" ,
15811581 fileNamePrefix : Optional [str ] = None ,
15821582 includeResources : bool = True ,
1583- ) -> str :
1583+ ) -> pathlib . Path :
15841584 """Translate the model into a Functional Mockup Unit.
15851585
15861586 Args:
@@ -1605,29 +1605,36 @@ def convertMo2Fmu(
16051605 properties = (f'version="{ version } ", fmuType="{ fmuType } ", '
16061606 f'fileNamePrefix="{ fileNamePrefix } ", includeResources={ includeResourcesStr } ' )
16071607 fmu = self ._requestApi (apiName = 'buildModelFMU' , entity = self ._model_name , properties = properties )
1608+ fmu_path = pathlib .Path (fmu )
16081609
16091610 # report proper error message
1610- if not os . path . exists ( fmu ):
1611- raise ModelicaSystemError (f"Missing FMU file: { fmu } " )
1611+ if not fmu_path . is_file ( ):
1612+ raise ModelicaSystemError (f"Missing FMU file: { fmu . as_posix () } " )
16121613
1613- return fmu
1614+ return fmu_path
16141615
16151616 # to convert FMU to Modelica model
1616- def convertFmu2Mo (self , fmuName ): # 20
1617+ def convertFmu2Mo (
1618+ self ,
1619+ fmuName : os .PathLike ,
1620+ ) -> pathlib .Path :
16171621 """
16181622 In order to load FMU, at first it needs to be translated into Modelica model. This method is used to generate Modelica model from the given FMU. It generates "fmuName_me_FMU.mo".
16191623 Currently, it only supports Model Exchange conversion.
16201624 usage
16211625 >>> convertFmu2Mo("c:/BouncingBall.Fmu")
16221626 """
16231627
1624- fileName = self ._requestApi (apiName = 'importFMU' , entity = fmuName )
1628+ fmu_path = pathlib .Path (fmuName )
1629+
1630+ filename = self ._requestApi (apiName = 'importFMU' , entity = fmu_path .as_posix ())
1631+ filepath = pathlib .Path (filename )
16251632
16261633 # report proper error message
1627- if not os . path . exists ( fileName ):
1628- raise ModelicaSystemError (f"Missing file { fileName } " )
1634+ if not filepath . is_file ( ):
1635+ raise ModelicaSystemError (f"Missing file { filepath . as_posix () } " )
16291636
1630- return fileName
1637+ return filepath
16311638
16321639 def optimize (self ) -> dict [str , Any ]:
16331640 """Perform model-based optimization.
0 commit comments