PluginProjectWeb.py

changeset 35
a3f1dcf94fe4
parent 34
a6d8718f37b5
child 38
6a12561fc0b5
diff -r a6d8718f37b5 -r a3f1dcf94fe4 PluginProjectWeb.py
--- a/PluginProjectWeb.py	Wed Dec 30 11:02:10 2020 +0100
+++ b/PluginProjectWeb.py	Mon Apr 26 17:47:56 2021 +0200
@@ -7,6 +7,7 @@
 Module implementing the Web project plugin.
 """
 
+import contextlib
 import os
 
 from PyQt5.QtCore import QObject, QTranslator
@@ -28,7 +29,7 @@
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "2.1.0"
+version = "2.2.0"
 className = "ProjectWebPlugin"
 packageName = "ProjectWeb"
 shortDescription = "Support for Web projects and web related tools."
@@ -54,7 +55,7 @@
         
         @param ui reference to the user interface object (UI.UserInterface)
         """
-        super(ProjectWebPlugin, self).__init__(ui)
+        super().__init__(ui)
         self.__ui = ui
         self.__initialize()
         
@@ -246,10 +247,8 @@
         
         @param editor reference to the editor (QScintilla.Editor)
         """
-        try:
+        with contextlib.suppress(KeyError):
             del self.__editors[editor]
-        except KeyError:
-            pass
     
     def __editorShowMenu(self, menuName, menu, editor):
         """
@@ -260,15 +259,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 __html5ToCss3(self):
         """

eric ide

mercurial