@@ -1126,7 +1126,51 @@ def _strip_space(name):
11261126
11271127 raise ModelicaSystemError ("Unhandled input for strip_space()" )
11281128
1129- def _setMethodHelper (
1129+ def _prepare_inputdata (
1130+ self ,
1131+ rawinput : str | list [str ] | dict [str , str | int | float ],
1132+ ) -> dict [str , str ]:
1133+ """
1134+ Convert raw input to a structured dictionary {'key1': 'value1', 'key2': 'value2'}.
1135+ """
1136+
1137+ def prepare_str (str_in : str ) -> dict [str , str ]:
1138+ str_in = str_in .replace (" " , "" )
1139+ key_val_list : list [str ] = str_in .split ("=" )
1140+ if len (key_val_list ) != 2 :
1141+ raise ModelicaSystemError (f"Invalid 'key=value' pair: { str_in } " )
1142+
1143+ inputdata = {key_val_list [0 ]: key_val_list [1 ]}
1144+
1145+ return inputdata
1146+
1147+ if isinstance (rawinput , str ):
1148+ warnings .warn (message = "The definition of values to set should use a dictionary, "
1149+ "i.e. {'key1': 'val1', 'key2': 'val2', ...}. Please convert all cases which "
1150+ "use a string ('key=val') or list ['key1=val1', 'key2=val2', ...]" ,
1151+ category = DeprecationWarning ,
1152+ stacklevel = 3 )
1153+ return prepare_str (rawinput )
1154+
1155+ if isinstance (rawinput , list ):
1156+ warnings .warn (message = "The definition of values to set should use a dictionary, "
1157+ "i.e. {'key1': 'val1', 'key2': 'val2', ...}. Please convert all cases which "
1158+ "use a string ('key=val') or list ['key1=val1', 'key2=val2', ...]" ,
1159+ category = DeprecationWarning ,
1160+ stacklevel = 3 )
1161+
1162+ inputdata : dict [str , str ] = {}
1163+ for item in rawinput :
1164+ inputdata |= prepare_str (item )
1165+
1166+ return inputdata
1167+
1168+ if isinstance (rawinput , dict ):
1169+ inputdata = {key : str (val ) for key , val in rawinput .items ()}
1170+
1171+ return inputdata
1172+
1173+ def setMethodHelper (
11301174 self ,
11311175 inputdata : str | list [str ] | dict [str , str | int | float ],
11321176 classdata : dict [str , Any ],
0 commit comments