Ver Fonte

修改split_file方法

刘凡 há 2 anos atrás
pai
commit
26c2c129ca
1 ficheiros alterados com 5 adições e 1 exclusões
  1. 5 1
      utils/splitfile.py

+ 5 - 1
utils/splitfile.py

@@ -17,7 +17,11 @@ def split_file(file_dir, output_dir, endpoint=".py"):
     for file_path in walk_files(file_dir, endpoint):
         with open(file_path, 'r') as file:
             content = file.read()
-        root = ast.parse(content)
+        try:
+            root = ast.parse(content)
+        except Exception as e:
+            print("错误明细:", e.__class__.__name__, e, file_path)
+            continue
         file_id = 1
         for node in root.body:
             if isinstance(node, ast.FunctionDef):