From b483feca250598af808fe377778adbc659ee38b7 Mon Sep 17 00:00:00 2001 From: Vic Date: Fri, 12 Jun 2026 09:59:17 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C=20fi?= =?UTF-8?q?x=5Fimports.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fix_imports.py | 64 -------------------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 fix_imports.py diff --git a/fix_imports.py b/fix_imports.py deleted file mode 100644 index 7089352..0000000 --- a/fix_imports.py +++ /dev/null @@ -1,64 +0,0 @@ -import os -import re - - -def fix_pyside6_syntax(filepath): - """Исправляет устаревший синтаксис PySide6""" - with open(filepath, 'r', encoding='utf-8') as f: - content = f.read() - - # Замены - replacements = [ - (r'Qt\.Horizontal', 'Qt.Orientation.Horizontal'), - (r'Qt\.Vertical', 'Qt.Orientation.Vertical'), - (r'Qt\.LeftButton', 'Qt.MouseButton.LeftButton'), - (r'Qt\.RightButton', 'Qt.MouseButton.RightButton'), - (r'Qt\.MiddleButton', 'Qt.MouseButton.MiddleButton'), - (r'self\.RenderHint\.', 'QPainter.RenderHint.'), - (r'Qt\.KeepAspectRatio', 'Qt.AspectRatioMode.KeepAspectRatio'), - (r'Qt\.IgnoreAspectRatio', 'Qt.AspectRatioMode.IgnoreAspectRatio'), - (r'Qt\.ScrollBarAsNeeded', 'Qt.ScrollBarPolicy.ScrollBarAsNeeded'), - (r'Qt\.ScrollBarAlwaysOff', 'Qt.ScrollBarPolicy.ScrollBarAlwaysOff'), - (r'Qt\.ScrollBarAlwaysOn', 'Qt.ScrollBarPolicy.ScrollBarAlwaysOn'), - (r'Qt\.black', 'Qt.GlobalColor.black'), - (r'Qt\.white', 'Qt.GlobalColor.white'), - (r'Qt\.red', 'Qt.GlobalColor.red'), - (r'Qt\.green', 'Qt.GlobalColor.green'), - (r'Qt\.blue', 'Qt.GlobalColor.blue'), - (r'Qt\.yellow', 'Qt.GlobalColor.yellow'), - (r'Qt\.gray', 'Qt.GlobalColor.gray'), - (r'Qt\.darkGray', 'Qt.GlobalColor.darkGray'), - (r'Qt\.lightGray', 'Qt.GlobalColor.lightGray'), - (r'Qt\.transparent', 'Qt.GlobalColor.transparent'), - ] - - for old, new in replacements: - content = re.sub(old, new, content) - - # Добавляем импорт QPainter если нужно - if 'QPainter' not in content and any('RenderHint' in content for _ in []): - if 'from PySide6.QtGui import' in content: - content = content.replace( - 'from PySide6.QtGui import', - 'from PySide6.QtGui import QPainter, ' - ) - else: - content = 'from PySide6.QtGui import QPainter\n' + content - - with open(filepath, 'w', encoding='utf-8') as f: - f.write(content) - - print(f"Fixed: {filepath}") - - -# Проходим по всем файлам -for root, dirs, files in os.walk('.'): - for file in files: - if file.endswith('.py'): - filepath = os.path.join(root, file) - try: - fix_pyside6_syntax(filepath) - except Exception as e: - print(f"Error fixing {filepath}: {e}") - -print("Done!") \ No newline at end of file