Use regular dict in get_reverse_bindings_for.
Returning a defaultdict made the caller's code look confusing, as it wasn't clear why there wouldn't be a Keyerror in some cases. Instead, let the caller explicitly use `get`.
This commit is contained in:
parent
709470fbe6
commit
051a00804b
@ -278,7 +278,7 @@ def _get_cmd_completions(include_hidden, include_aliases, prefix=''):
|
||||
hide_debug = obj.debug and not objreg.get('args').debug
|
||||
hide_hidden = obj.hide and not include_hidden
|
||||
if not (hide_debug or hide_hidden or obj.deprecated):
|
||||
bindings = ', '.join(cmd_to_keys[obj.name])
|
||||
bindings = ', '.join(cmd_to_keys.get(obj.name, []))
|
||||
cmdlist.append((prefix + obj.name, obj.desc, bindings))
|
||||
|
||||
if include_aliases:
|
||||
|
@ -424,8 +424,9 @@ class KeyConfigParser(QObject):
|
||||
|
||||
def get_reverse_bindings_for(self, section):
|
||||
"""Get a dict of commands to a list of bindings for the section."""
|
||||
cmd_to_keys = collections.defaultdict(list)
|
||||
cmd_to_keys = {}
|
||||
for key, cmd in self.get_bindings_for(section).items():
|
||||
cmd_to_keys.setdefault(cmd, [])
|
||||
# put special bindings last
|
||||
if utils.is_special_key(key):
|
||||
cmd_to_keys[cmd].append(key)
|
||||
|
Loading…
Reference in New Issue
Block a user