#!/usr/bin/env python3
"""Remove duplicate UserSession class from models.py"""
with open('app/models.py', 'r') as f:
lines = f.readlines()
# Find all lines with "class UserSession"
positions = [i for i, line in enumerate(lines) if 'class UserSession' in line]
print(f"Found UserSession at lines: {positions}")
if len(positions) > 1:
# Remove the second occurrence (the duplicate I added)
# Find the start of the class
start = positions[-1]
# Find the next class definition or end of file
end = len(lines)
for i in range(start + 1, len(lines)):
if lines[i].strip().startswith('class '):
end = i
break
removed = lines[start:end]
print(f"Removing lines {start+1} to {end}:")
for line in removed[:5]:
print(f" {line.rstrip()}")
print(f" ... ({len(removed)} lines total)")
del lines[start:end]
with open('app/models.py', 'w') as f:
f.writelines(lines)
print(f"SUCCESS: Removed duplicate UserSession at line {start+1}")
else:
print("No duplicate found")