#!/usr/bin/env python3 """Fix schemas/__init__.py by removing proto_messages and protocol_constants imports.""" init_path = 'app/schemas/__init__.py' with open(init_path, 'r') as f: lines = f.readlines() # Find and remove the proto_messages import block new_lines = [] skip_until_close_paren = False skip_comment = False i = 0 while i < len(lines): line = lines[i] # Skip proto_messages import block if 'from app.schemas.proto_messages import' in line: # Skip until we find the closing paren while i < len(lines) and ')' not in lines[i]: i += 1 i += 1 # skip the closing paren line continue # Skip protocol_constants import block if 'from app.schemas.protocol_constants import' in line: while i < len(lines) and ')' not in lines[i]: i += 1 i += 1 continue # Skip proto_messages and protocol_constants entries in __all__ if '# Proto Messages' in line: skip_comment = True i += 1 continue if '# Protocol Constants' in line: i += 1 continue if skip_comment: # Skip lines until we hit the next comment or end of __all__ if line.strip().startswith('"') and not line.strip().startswith('"):'): # This is still part of the proto/protocol entries i += 1 continue else: skip_comment = False new_lines.append(line) i += 1 continue new_lines.append(line) i += 1 with open(init_path, 'w') as f: f.writelines(new_lines) print(f"Fixed {init_path}") print(f"Original: {len(lines)} lines, New: {len(new_lines)} lines")