@@ -189,6 +189,26 @@ def get_exe_file(self, tempdir, modelName) -> pathlib.Path:
189189 else :
190190 return pathlib .Path (tempdir ) / modelName
191191
192+ def parse_simflags (self , simflags : str ) -> dict :
193+ # add old style simulation arguments
194+ warnings .warn ("The argument 'simflags' is depreciated and will be removed in future versions; "
195+ "please use 'simargs' instead" , DeprecationWarning , stacklevel = 2 )
196+
197+ simargs = {}
198+
199+ args = [s for s in simflags .split (' ' ) if s ]
200+ for arg in args :
201+ if arg [0 ] != '-' :
202+ raise ModelicaSystemError (f"Invalid simulation flag: { arg } " )
203+ arg = arg [1 :]
204+ parts = arg .split ('=' )
205+ if len (parts ) == 1 :
206+ simargs [parts [0 ]] = None
207+ else :
208+ simargs [parts [0 ]] = '=' .join (parts [1 :])
209+
210+ return simargs
211+
192212
193213class ModelicaSystem :
194214 def __init__ (
@@ -709,23 +729,8 @@ def simulate(self, resultfile: Optional[str] = None, simflags: Optional[str] = N
709729 om_cmd .arg_set (key = "r" , val = self .resultfile )
710730
711731 # allow runtime simulation flags from user input
712- # TODO: merge into ModelicaSystemCmd?
713732 if simflags is not None :
714- # add old style simulation arguments
715- warnings .warn ("The argument simflags is depreciated and will be removed in future versions; "
716- "please use simargs instead" , DeprecationWarning , stacklevel = 1 )
717-
718- args = [s for s in simflags .split (' ' ) if s ]
719- for arg in args :
720- if arg [0 ] != '-' :
721- raise ModelicaSystemError (f"Invalid simulation flag: { arg } " )
722- arg = arg [1 :]
723- parts = arg .split ('=' )
724- if len (parts ) == 1 :
725- val = None
726- else :
727- val = '=' .join (parts [1 :])
728- om_cmd .arg_set (key = parts [0 ], val = val )
733+ om_cmd .args_set (args = om_cmd .parse_simflags (simflags = simflags ))
729734
730735 if simargs :
731736 om_cmd .args_set (args = simargs )
@@ -1123,22 +1128,8 @@ def linearize(self, lintime: Optional[float] = None, simflags: Optional[str] = N
11231128 om_cmd .arg_set (key = "l" , val = f"{ lintime or self .linearOptions ["stopTime" ]} " )
11241129
11251130 # allow runtime simulation flags from user input
1126- # TODO: merge into ModelicaSystemCmd?
11271131 if simflags is not None :
1128- # add old style simulation arguments
1129- warnings .warn ("The argument simflags is depreciated and will be removed in future versions; "
1130- "please use simargs instead" , DeprecationWarning , stacklevel = 1 )
1131-
1132- args = [s for s in simflags .split (' ' ) if s ]
1133- for arg in args :
1134- if arg [0 ] != '-' :
1135- raise ModelicaSystemError (f"Invalid simulation flag: { arg } " )
1136- parts = arg .split ('=' )
1137- if len (parts ) == 1 :
1138- val = None
1139- else :
1140- val = '=' .join (parts [1 :])
1141- om_cmd .arg_set (key = parts [0 ], val = val )
1132+ om_cmd .args_set (args = om_cmd .parse_simflags (simflags = simflags ))
11421133
11431134 if simargs :
11441135 om_cmd .args_set (args = simargs )
0 commit comments