@@ -1543,7 +1543,7 @@ def convertMo2Fmu(
15431543 fmuType : str = "me_cs" ,
15441544 fileNamePrefix : Optional [str ] = None ,
15451545 includeResources : bool = True ,
1546- ) -> str :
1546+ ) -> pathlib . Path :
15471547 """Translate the model into a Functional Mockup Unit.
15481548
15491549 Args:
@@ -1568,29 +1568,36 @@ def convertMo2Fmu(
15681568 properties = (f'version="{ version } ", fmuType="{ fmuType } ", '
15691569 f'fileNamePrefix="{ fileNamePrefix } ", includeResources={ includeResourcesStr } ' )
15701570 fmu = self ._requestApi (apiName = 'buildModelFMU' , entity = self ._model_name , properties = properties )
1571+ fmu_path = pathlib .Path (fmu )
15711572
15721573 # report proper error message
1573- if not os . path . exists ( fmu ):
1574- raise ModelicaSystemError (f"Missing FMU file: { fmu } " )
1574+ if not fmu_path . is_file ( ):
1575+ raise ModelicaSystemError (f"Missing FMU file: { fmu . as_posix () } " )
15751576
1576- return fmu
1577+ return fmu_path
15771578
15781579 # to convert FMU to Modelica model
1579- def convertFmu2Mo (self , fmuName ): # 20
1580+ def convertFmu2Mo (
1581+ self ,
1582+ fmuName : os .PathLike ,
1583+ ) -> pathlib .Path :
15801584 """
15811585 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".
15821586 Currently, it only supports Model Exchange conversion.
15831587 usage
15841588 >>> convertFmu2Mo("c:/BouncingBall.Fmu")
15851589 """
15861590
1587- fileName = self ._requestApi (apiName = 'importFMU' , entity = fmuName )
1591+ fmu_path = pathlib .Path (fmuName )
1592+
1593+ filename = self ._requestApi (apiName = 'importFMU' , entity = fmu_path .as_posix ())
1594+ filepath = pathlib .Path (filename )
15881595
15891596 # report proper error message
1590- if not os . path . exists ( fileName ):
1591- raise ModelicaSystemError (f"Missing file { fileName } " )
1597+ if not filepath . is_file ( ):
1598+ raise ModelicaSystemError (f"Missing file { filepath . as_posix () } " )
15921599
1593- return fileName
1600+ return filepath
15941601
15951602 def optimize (self ) -> dict [str , Any ]:
15961603 """Perform model-based optimization.
0 commit comments