PluginPySide2PyQt.py

changeset 53
52bc3465c1bc
parent 52
c88593752c63
child 55
f9706d6a2ece
--- a/PluginPySide2PyQt.py	Wed Dec 30 11:02:15 2020 +0100
+++ b/PluginPySide2PyQt.py	Mon Apr 26 19:51:49 2021 +0200
@@ -7,6 +7,7 @@
 Module implementing the PySide to PyQt (and vice versa) plug-in.
 """
 
+import contextlib
 import os
 
 from PyQt5.QtCore import QObject, QTranslator
@@ -19,7 +20,7 @@
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "3.0.0"
+version = "3.1.0"
 className = "PySide2PyQtPlugin"
 packageName = "PySide2PyQt"
 shortDescription = "Convert PySide file to PyQt and vice versa"
@@ -44,7 +45,7 @@
         
         @param ui reference to the user interface object (UI.UserInterface)
         """
-        QObject.__init__(self, ui)
+        super.__init__(ui)
         self.__ui = ui
         
         self.__translator = None
@@ -184,12 +185,10 @@
         
         @param editor reference to the editor (QScintilla.Editor)
         """
-        try:
+        with contextlib.suppress(KeyError):
             del self.__editors[editor]
             if not self.__editors:
                 self.__menu.setEnabled(False)
-        except KeyError:
-            pass
     
     def __editorShowMenu(self, menuName, menu, editor):
         """
@@ -200,15 +199,17 @@
         @param menu reference to the menu (QMenu)
         @param editor reference to the editor
         """
-        if menuName == "Tools":
-            if self.__menu.menuAction() not in menu.actions():
-                # Re-add our menu
-                self.__editors[editor] = []
-                if not menu.isEmpty():
-                    act = menu.addSeparator()
-                    self.__editors[editor].append(act)
-                act = menu.addMenu(self.__menu)
+        if (
+            menuName == "Tools" and
+            self.__menu.menuAction() not in menu.actions()
+        ):
+            # Re-add our menu
+            self.__editors[editor] = []
+            if not menu.isEmpty():
+                act = menu.addSeparator()
                 self.__editors[editor].append(act)
+            act = menu.addMenu(self.__menu)
+            self.__editors[editor].append(act)
     
     def __pyside2Pyqt(self, pyside, pyqt):
         """

eric ide

mercurial