From 04140d97773b7002642e7d180125ab305f2944b2 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 17 Jan 2014 11:14:19 +0100 Subject: [PATCH] Remove explicit command name --- qutebrowser/commands/commands.py | 6 ------ qutebrowser/commands/utils.py | 13 +++++++------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/qutebrowser/commands/commands.py b/qutebrowser/commands/commands.py index 3f2f41d58..2b8b00310 100644 --- a/qutebrowser/commands/commands.py +++ b/qutebrowser/commands/commands.py @@ -8,35 +8,29 @@ class Empty(Command): class Open(Command): nargs = 1 - name = 'open' key = 'o' signal = pyqtSignal(str) class TabOpen(Command): nargs = 1 - name = 'tabopen' key = 'Shift+o' signal = pyqtSignal(str) class TabClose(Command): nargs = 0 - name = 'tabclose' key = 'd' signal = pyqtSignal() class TabNext(Command): nargs = 0 - name = 'tabnext' key = 'Shift+j' signal = pyqtSignal() class TabPrev(Command): nargs = 0 - name = 'tabprev' key = 'Shift+k' signal = pyqtSignal() class Quit(Command): nargs = 0 - name = 'quit' signal = pyqtSignal() diff --git a/qutebrowser/commands/utils.py b/qutebrowser/commands/utils.py index e243408c4..60eb90c3c 100644 --- a/qutebrowser/commands/utils.py +++ b/qutebrowser/commands/utils.py @@ -10,7 +10,12 @@ def register_all(): obj.__module__ == 'qutebrowser.commands.commands') for (name, cls) in inspect.getmembers(commands, is_cmd): - cls.bind() + if cls.bind: + if cls.name is None: + name = cls.__name__.tolower() + else: + name = cls.name + cmd_dict[name] = cls() class CommandParser(QObject): error = pyqtSignal(str) @@ -36,11 +41,7 @@ class Command(QObject): name = None key = None signal = None - - @classmethod - def bind(cls): - if cls.name is not None: - cmd_dict[cls.name] = cls() + bind = True def check(self, argv): if ((isinstance(self.nargs, int) and len(argv) != self.nargs) or