eric6/Preferences/Shortcuts.py

branch
maintenance
changeset 8273
698ae46f40a4
parent 8176
31965986ecd1
parent 8243
cc717c2ae956
--- a/eric6/Preferences/Shortcuts.py	Fri Apr 02 11:59:41 2021 +0200
+++ b/eric6/Preferences/Shortcuts.py	Sat May 01 14:27:20 2021 +0200
@@ -7,6 +7,8 @@
 Module implementing functions dealing with keyboard shortcuts.
 """
 
+import contextlib
+
 from PyQt5.QtCore import QFile, QIODevice, QCoreApplication
 from PyQt5.QtGui import QKeySequence
 
@@ -95,15 +97,12 @@
             __readShortcut(act, helpViewerCategory, prefClass)
     
     if pluginName is not None:
-        try:
+        with contextlib.suppress(KeyError):
             ref = e5App().getPluginObject(pluginName)
             if hasattr(ref, "getActions"):
                 actions = ref.getActions()
                 for act in actions:
                     __readShortcut(act, pluginName, prefClass)
-        except KeyError:
-            # silently ignore non available plugins
-            pass
     
 
 def __saveShortcut(act, category, prefClass):
@@ -292,13 +291,11 @@
     """
     for act in actions:
         if act.objectName():
-            try:
+            with contextlib.suppress(KeyError):
                 accel, altAccel = shortcutsDict[act.objectName()]
                 act.setShortcut(QKeySequence(accel))
                 act.setAlternateShortcut(QKeySequence(altAccel),
                                          removeEmpty=True)
-            except KeyError:
-                pass
 
 
 def setActions(shortcuts, helpViewer=None):

eric ide

mercurial