eric6/Preferences/Shortcuts.py

changeset 8243
cc717c2ae956
parent 8143
2c730d5fd177
child 8273
698ae46f40a4
diff -r aa713ac50c0d -r cc717c2ae956 eric6/Preferences/Shortcuts.py
--- a/eric6/Preferences/Shortcuts.py	Thu Apr 15 16:52:05 2021 +0200
+++ b/eric6/Preferences/Shortcuts.py	Thu Apr 15 18:11:24 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