Browse Source

修改split_file方法

刘凡 2 years ago
parent
commit
26c2c129ca
1 changed files with 5 additions and 1 deletions
  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):