#!/usr/bin/env python3 """Fix QPainterPath includes from QtCore to QtGui""" import os import re import sys def fix_qpainterpath_includes(root_dir): """Fix QPainterPath includes from QtCore to QtGui""" files_fixed = 0 total_fixes = 0 # Walk through all directories for dirpath, dirnames, filenames in os.walk(root_dir): # Skip build directories if 'build' in dirpath or dirpath.endswith('/build'): continue for filename in filenames: if filename.endswith('.h') or filename.endswith('.cpp'): filepath = os.path.join(dirpath, filename) try: with open(filepath, 'r', encoding='utf-8', errors='ignore') as f: content = f.read() # Check for QtCore/QPainterPath if '' in content: # Replace with QtGui/QPainterPath new_content = content.replace('', '') with open(filepath, 'w', encoding='utf-8') as f: f.write(new_content) files_fixed += 1 total_fixes += content.count('') print(f"Fixed: {filepath}") except (PermissionError, OSError) as e: # Skip files we can't access (build directories) pass print(f"\nFixed QPainterPath includes: {files_fixed} files, {total_fixes} total fixes") return files_fixed, total_fixes if __name__ == '__main__': root_dir = sys.argv[1] if len(sys.argv) > 1 else '.' fix_qpainterpath_includes(root_dir)