# Script to fix the syntax error in admin_routes.py

file_path = r'd:\bookbeach\backend\app\routes\admin_routes.py'

# Read the file
with open(file_path, 'r', encoding='utf-8') as f:
    lines = f.readlines()

# Find and fix the syntax error
# Look for the pattern that causes the syntax error
fixed_lines = []
i = 0
while i < len(lines):
    line = lines[i]
    
    # Check if we have the problematic pattern
    if (i + 1 < len(lines) and 
        lines[i].strip() == '' and 
        i + 2 < len(lines) and 
        lines[i + 1].strip() == '' and
        i + 3 < len(lines) and
        lines[i + 2].strip() == '' and
        i + 4 < len(lines) and
        lines[i + 3].strip().startswith('@admin_bp.route')):
        # Skip extra blank lines
        print(f"Found extra blank lines at {i}, skipping...")
        # Skip until we reach the route decorator
        while i < len(lines) and lines[i].strip() == '':
            i += 1
        # Add the route decorator line
        if i < len(lines):
            fixed_lines.append(lines[i])
            i += 1
    else:
        fixed_lines.append(line)
        i += 1

# Write the fixed content back
with open(file_path, 'w', encoding='utf-8') as f:
    f.writelines(fixed_lines)

print("Fixed syntax error in admin_routes.py")