@@ -402,23 +402,28 @@ def model(
402402 self ._libraries = libraries # may be needed if model is derived from other model
403403 self ._variable_filter = variable_filter
404404
405+ if self ._libraries :
406+ self ._loadLibrary (libraries = self ._libraries )
407+
408+ self ._file_name = None
405409 if file is not None :
410+ file_path = pathlib .Path (file )
406411 # special handling for OMCProcessLocal - consider a relative path
407- if isinstance (self ._session .omc_process , OMCProcessLocal ):
408- file_path = pathlib .Path (file )
409- if not file_path .is_absolute ():
410- file_path = pathlib .Path .cwd () / file_path
412+ if isinstance (self ._session .omc_process , OMCProcessLocal ) and not file_path .is_absolute ():
413+ file_path = pathlib .Path .cwd () / file_path
414+ if not file_path .is_file ():
415+ raise IOError (f"Model file { file_path } does not exist!" )
416+
417+ self ._file_name = self .getWorkDirectory () / file_path .name
418+ if (isinstance (self ._session .omc_process , OMCProcessLocal )
419+ and file_path .as_posix () == self ._file_name .as_posix ()):
420+ pass
421+ elif self ._file_name .is_file ():
422+ raise IOError (f"Simulation model file { self ._file_name } exist - not overwriting!" )
411423 else :
412- file_path = self ._session .omcpath (file ).resolve ()
424+ content = file_path .read_text (encoding = 'utf-8' )
425+ self ._file_name .write_text (content )
413426
414- self ._file_name = self ._session .omcpath (file_path )
415- if not self ._file_name .is_file ():
416- raise IOError (f"{ self ._file_name } does not exist!" )
417- else :
418- self ._file_name = None
419-
420- if self ._libraries :
421- self ._loadLibrary (libraries = self ._libraries )
422427 if self ._file_name is not None :
423428 self ._loadFile (fileName = self ._file_name )
424429
0 commit comments