@@ -156,6 +156,33 @@ def safe_literal_eval(filename, defaultValue):
156156# ===================================================================
157157# Parameter Parsing
158158# ===================================================================
159+ def parse_params (sparams : str ) -> dict :
160+ """Parse semicolon-delimited key=value pairs into a dictionary.
161+
162+ Args:
163+ sparams: String in format "key1=value1;key2=value2"
164+
165+ Returns:
166+ Dictionary with parsed key-value pairs
167+ """
168+ params = {}
169+ if not sparams :
170+ return params
171+
172+ for item in sparams .split (";" ):
173+ if "=" in item :
174+ key , value = item .split ("=" , 1 ) # split only once
175+ key = key .strip ()
176+ value = value .strip ()
177+ #try to convert to python type (int, float, list, etc.)
178+ # Use literal_eval to preserve backward compatibility (integers/lists)
179+ # Fallback to string for unquoted values (paths, URLs)
180+ try :
181+ params [key ] = literal_eval (value )
182+ except (ValueError , SyntaxError ):
183+ params [key ] = value
184+ return params
185+
159186try :
160187 sparams_path = concore_params_file
161188 if os .path .exists (sparams_path ):
@@ -166,16 +193,10 @@ def safe_literal_eval(filename, defaultValue):
166193 if sparams [0 ] == '"' and sparams [- 1 ] == '"' : #windows keeps "" need to remove
167194 sparams = sparams [1 :- 1 ]
168195
169- # Convert key=value;key2=value2 to Python dict format
170- if sparams != '{' and not (sparams .startswith ('{' ) and sparams .endswith ('}' )): # Check if it needs conversion
171- logging .debug ("converting sparams: " + sparams )
172- sparams = "{'" + re .sub (';' ,",'" ,re .sub ('=' ,"':" ,re .sub (' ' ,'' ,sparams )))+ "}"
173- logging .debug ("converted sparams: " + sparams )
174- try :
175- params = literal_eval (sparams )
176- except Exception as e :
177- logging .warning (f"bad params content: { sparams } , error: { e } " )
178- params = dict ()
196+ # Parse params using clean function instead of regex
197+ logging .debug ("parsing sparams: " + sparams )
198+ params = parse_params (sparams )
199+ logging .debug ("parsed params: " + str (params ))
179200 else :
180201 params = dict ()
181202 else :
0 commit comments