goat / Scripts /_check_syntax.py
LightChuan's picture
Upload folder using huggingface_hub
6a5bb7e verified
Raw
History Blame Contribute Delete
411 Bytes
import ast, sys
files = [
'E:/DairyGoat/Scripts/train_baseline.py',
]
for path in files:
try:
with open(path, encoding='utf-8') as f:
source = f.read()
ast.parse(source)
print(f'{path} 语法正确')
except FileNotFoundError:
print(f'{path} 不存在,跳过')
except SyntaxError as e:
print(f'{path} 语法错误: {e}')
sys.exit(1)