@@ -15,17 +15,19 @@ def check(cond, msg, is_warn=False):
1515 if not cond :
1616 (warnings if is_warn else errors ).append (msg )
1717
18- def get_valid_tags (root_yaml_path = 'data.yaml' ):
19- if not os .path .isfile (root_yaml_path ):
20- print (f"⚠️ 未找到根配置文件 { root_yaml_path } ,跳过 tags 校验" )
18+ def get_valid_tags ():
19+ root = os .path .join (os .path .dirname (os .path .abspath (__file__ )), '../..' )
20+ yaml_path = os .path .join (root , 'tools/data.yaml' )
21+ if not os .path .isfile (yaml_path ):
22+ print (f"⚠️ 未找到 tools/data.yaml,跳过 tags 校验" )
2123 return set ()
2224 try :
23- with open (root_yaml_path , encoding = 'utf-8' ) as f :
25+ with open (yaml_path , encoding = 'utf-8' ) as f :
2426 data = yaml .safe_load (f )
2527 tags = data .get ('additionalProperties' , {}).get ('tags' , [])
2628 return {tag ['name' ] for tag in tags if 'name' in tag }
2729 except yaml .YAMLError as e :
28- print (f"⚠️ 根配置文件解析失败 : { e } " )
30+ print (f"⚠️ tools/data.yaml 解析失败 : { e } " )
2931 return set ()
3032
3133def get_changed_tool_dirs (changed_files_path ):
@@ -99,11 +101,11 @@ def validate_tool_dir(tool_path, valid_tags):
99101 logo_path = os .path .join (tool_path , 'logo.png' )
100102 if os .path .isfile (logo_path ):
101103 size_kb = os .path .getsize (logo_path ) / 1024
102- check (size_kb <= 500 , f"[{ tool_name } ] logo.png 文件过大 ({ size_kb :.1f} KB),建议不超过 500KB" , is_warn = True )
104+ check (size_kb <= 500 , f"[{ tool_name } ] logo.png 过大 ({ size_kb :.1f} KB),建议不超过 500KB" , is_warn = True )
103105
104106def main ():
105107 changed_files_path = sys .argv [1 ]
106- valid_tags = get_valid_tags ('data.yaml' )
108+ valid_tags = get_valid_tags ()
107109 tool_dirs = get_changed_tool_dirs (changed_files_path )
108110
109111 if not tool_dirs :
0 commit comments