@@ -59,6 +59,9 @@ pl_python_uv_config_define_python (char *path)
5959 PlPythonUvConfig config = {true, NULL , NULL };
6060
6161 char * content = xy_file_read (path );
62+ if (!content || strlen (content ) == 0 )
63+ return config ;
64+
6265 char * formatted = xy_str_gsub (content , " " , "" );
6366 formatted = xy_str_gsub (formatted , "'" , "\"" );
6467
@@ -69,6 +72,7 @@ pl_python_uv_config_define_python (char *path)
6972 url = xy_str_gsub (url , "\"" , "" );
7073 url = xy_str_delete_prefix (url , "=" );
7174 config .url = url ;
75+ config .file_path = xy_strdup (path );
7276 config .is_empty = !config .url ;
7377 }
7478 return config ;
@@ -80,6 +84,9 @@ pl_python_uv_config_define_pypi (char *path)
8084 PlPythonUvConfig config = {true, NULL , NULL };
8185
8286 char * content = xy_file_read (path );
87+ if (!content || strlen (content ) == 0 )
88+ return config ;
89+
8390 char * formatted = xy_str_gsub (content , " " , "" );
8491 formatted = xy_str_gsub (formatted , "'" , "\"" );
8592
@@ -102,10 +109,14 @@ pl_python_uv_config_define_pypi (char *path)
102109 /* 循环读取下一行,直到找到包含 "url" 的行 */
103110 while (* current_pos != '\0' )
104111 {
105- url = xy_str_next_nonempty_line (current_pos );
106- if (url && xy_str_find (url , "url" ).found )
107- break ;
108-
112+ char * line = xy_str_next_nonempty_line (current_pos );
113+ if (line && xy_str_find (line , "url" ).found )
114+ {
115+ url = line ;
116+ break ;
117+ }
118+
119+ /* 移动到下一行的位置 */
109120 current_pos = strchr (current_pos , '\n' );
110121 if (!current_pos )
111122 break ;
@@ -114,19 +125,20 @@ pl_python_uv_config_define_pypi (char *path)
114125
115126 if (url )
116127 {
117- config .is_empty = false;
118128 url = xy_str_gsub (url , "\"" , "" );
119129 url = xy_str_delete_prefix (url , "=" );
120130 config .url = url ;
131+ config .file_path = xy_strdup (path );
132+ config .is_empty = !config .url ;
121133 }
122- else config .is_empty = true;
123134 }
124135 else
125136 {
126137 char * url = xy_str_next_nonempty_line (formatted + new_sytle_result .end + 1 );
127138 url = xy_str_gsub (url , "\"" , "" );
128139 url = xy_str_delete_prefix (url , "=" );
129140 config .url = url ;
141+ config .file_path = xy_strdup (path );
130142 config .is_empty = !config .url ;
131143 }
132144 return config ;
@@ -254,24 +266,32 @@ pl_python_uv_getsrc (char *option)
254266{
255267 PlPythonUvConfigSummary uv_config = pl_python_uv_config_find ();
256268
257- if (uv_config .pypi == false && uv_config . python == false )
269+ if (uv_config .pypi )
258270 {
259- char * msg = ENGLISH ? "Can't find uv config, show default."
260- : "未找到 uv 的配置文件,显示默认值" ;
271+ chsrc_note2 ("uv pypi:" );
272+ say (xy_2strcat (ENGLISH ? "Config Path: " : "文件路径:" , uv_config .pypi_path ));
273+ say (uv_config .pypi_url );
274+ }
275+ else
276+ {
277+ char * msg = ENGLISH ? "Can't find uv config for pypi, show default."
278+ : "未找到 uv 关于 pypi 的配置文件,显示默认值" ;
261279 chsrc_note2 (msg );
262-
263- chsrc_note2 ("Python: " );
264- say ("https://github.com/astral-sh/python-build-standalone/releases/download" );
265-
266- chsrc_note2 ("Pypi: " );
267280 say ("https://pypi.org/simple" );
268281 }
282+
283+ if (uv_config .python )
284+ {
285+ chsrc_note2 ("uv Python:" );
286+ say (xy_2strcat (ENGLISH ? "Config Path: " : "文件路径:" , uv_config .python_path ));
287+ say (uv_config .python_url );
288+ }
269289 else
270290 {
271- chsrc_note2 ( " uv Python: " );
272- say ( xy_strcat ( 4 , uv_config . python_url , " ()" , uv_config . python_path , ")" ) ) ;
273- chsrc_note2 ("uv Pypi: " );
274- say (xy_strcat ( 4 , uv_config . pypi_url , " ()" , uv_config . pypi_path , ")" ) );
291+ char * msg = ENGLISH ? "Can't find uv config for Python, show default."
292+ : "未找到 uv 关于 Python 的配置文件,显示默认值" ;
293+ chsrc_note2 (msg );
294+ say ("https://github.com/astral-sh/python-build-standalone/releases/download" );
275295 }
276296}
277297
0 commit comments