@@ -76,6 +76,37 @@ def convert_raw_to_processed(raw_yaml: str) -> str:
7676 except Exception as e :
7777 print (f"查询operator_config_select_options失败: { e } " )
7878 pass
79+ # handle_string_array_format_like_"['1','2']"_or_"[''1'', ''2'']"
80+ elif param_value and isinstance (param_value , str ) and param_value .startswith ('[' ) and param_value .endswith (']' ):
81+ try :
82+ import ast
83+ # try_to_parse_the_string_array
84+ # First, handle the double single quote escape format [" 1 ", "2"] -> [" 1 ", "2"]
85+ normalized_value = param_value .replace ("''" , "'" )
86+ parsed_list = ast .literal_eval (normalized_value )
87+ if isinstance (parsed_list , list ):
88+ from data_server .operator .mapper .operator_mapper import get_operator_config_select_option_by_id
89+ from data_server .database .session import get_sync_session
90+ converted_list = []
91+ for item in parsed_list :
92+ if isinstance (item , str ) and item .isdigit ():
93+ try :
94+ db = get_sync_session ()
95+ option_record = get_operator_config_select_option_by_id (db , int (item ))
96+ if option_record and hasattr (option_record , 'name' ):
97+ converted_list .append (option_record .name )
98+ else :
99+ converted_list .append (item )
100+ db .close ()
101+ except Exception as e :
102+ print (f"查询operator_config_select_options失败: { e } " )
103+ converted_list .append (item )
104+ else :
105+ converted_list .append (item )
106+ param_value = converted_list
107+ except (ValueError , SyntaxError ) as e :
108+ print (f"解析字符串数组失败: { e } " )
109+ pass
79110 # handle_the_numeric_id_of_list_type
80111 elif param_value and isinstance (param_value , list ):
81112 from data_server .operator .mapper .operator_mapper import get_operator_config_select_option_by_id
@@ -135,8 +166,13 @@ def convert_string_list_to_yaml(match):
135166 return f"{ param_name } : { list_content } "
136167
137168 # regular_expressions_match_lists_in_string_format
138- pattern = r"(\s+\w+):\s*'(\[.*?\])'"
139- yaml_str = re .sub (pattern , convert_string_list_to_yaml , yaml_str )
169+ # 匹配单引号包裹的字符串数组:'[...]'
170+ pattern1 = r"(\s+\w+):\s*'(\[.*?\])'"
171+ yaml_str = re .sub (pattern1 , convert_string_list_to_yaml , yaml_str )
172+
173+ # 匹配双引号包裹的字符串数组:"[...]"
174+ pattern2 = r'(\s+\w+):\s*"(\[.*?\])"'
175+ yaml_str = re .sub (pattern2 , convert_string_list_to_yaml , yaml_str )
140176
141177 yaml_str = yaml_str .replace (": {}" , ":" )
142178
@@ -207,7 +243,7 @@ def convert_string_list_to_yaml(match):
207243 default_value: '18'
208244 is_required: false
209245 is_spinner: false
210- final_value: '18 '
246+ final_value: '[''41'', ''42'', ''43'', ''44'', ''45''] '
211247 display_name: 模型名称
212248edges: []
213249
0 commit comments