File size: 1,080 Bytes
c922f8b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
Simple script to check app.py for syntax errors and identify line numbers
"""
import os
import sys
import traceback

def check_file_syntax(file_path):
    print(f"Checking syntax for: {file_path}")
    
    try:
        with open(file_path, 'r', encoding='utf-8') as f:
            source = f.read()
            
        # Try to compile the source code
        compiled = compile(source, file_path, 'exec')
        print(f"✓ {file_path} has valid Python syntax")
        return True
    except SyntaxError as e:
        print(f"✗ Syntax error in {file_path}:")
        print(f"  Line {e.lineno}, Column {e.offset}: {e.text}")
        print(f"  {e}")
        return False
    except Exception as e:
        print(f"✗ Error checking {file_path}:")
        print(f"  {e}")
        traceback.print_exc()
        return False

if __name__ == "__main__":
    app_path = "app.py"
    if not os.path.exists(app_path):
        print(f"File not found: {app_path}")
        sys.exit(1)
        
    if check_file_syntax(app_path):
        sys.exit(0)
    else:
        sys.exit(1)