
import os
import sys


print("Starting concatenation...")

base_path = r"c:\Users\Apurv.Gupta\.gemini\antigravity\scratch\askmebackend\askmebackend\app\routes"

parts = [
    os.path.join(base_path, "admin_options_async_part1.py"),
    os.path.join(base_path, "admin_options_async_part2.py"),
    os.path.join(base_path, "admin_options_async_part3.py"),
    os.path.join(base_path, "admin_options_async_part4.py"),
    os.path.join(base_path, "admin_options_async_part5.py")
]

output_file = os.path.join(base_path, "admin_options_async_final.py")

try:
    with open(output_file, "wb") as outfile:
        for part in parts:
            if os.path.exists(part):
                print(f"Reading {part}...")
                with open(part, "rb") as infile:
                    content = infile.read()
                    outfile.write(content)
                    # Ensure there is a newline between parts if not present
                    if not content.endswith(b'\n'):
                        outfile.write(b"\n")
            else:
                print(f"Error: {part} not found!")
                sys.exit(1)
    print(f"Successfully created {output_file}")
    print(f"File size: {os.path.getsize(output_file)} bytes")
except Exception as e:
    print(f"Error: {e}")
    sys.exit(1)

