From 226adac899be7198f2fb2d2f44fa57af283d9869 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 22 Jan 2014 17:31:15 +0100 Subject: [PATCH] Rename parse_check_run to run in CommandParser --- qutebrowser/app.py | 3 +-- qutebrowser/commands/keys.py | 3 +-- qutebrowser/commands/utils.py | 16 ++++++++-------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 3826f4270..e067a5be6 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -44,8 +44,7 @@ class QuteBrowser(QApplication): self.aboutToQuit.connect(self.config.save) self.mainwindow.tabs.keypress.connect(self.keyparser.handle) self.keyparser.set_cmd_text.connect(self.mainwindow.status.cmd.set_cmd) - self.mainwindow.status.cmd.got_cmd.connect( - self.commandparser.parse_check_run) + self.mainwindow.status.cmd.got_cmd.connect(self.commandparser.run) self.mainwindow.status.cmd.got_cmd.connect( self.mainwindow.tabs.setFocus) self.commandparser.error.connect(self.mainwindow.status.disp_error) diff --git a/qutebrowser/commands/keys.py b/qutebrowser/commands/keys.py index 39a28ed65..5881cc80c 100644 --- a/qutebrowser/commands/keys.py +++ b/qutebrowser/commands/keys.py @@ -87,8 +87,7 @@ class KeyParser(QObject): count = int(countstr) if countstr else None try: - self.commandparser.parse_check_run(cmdstr_hay, count=count, - ignore_exc=False) + self.commandparser.run(cmdstr_hay, count=count, ignore_exc=False) except NoSuchCommandError: return except ArgumentCountError: diff --git a/qutebrowser/commands/utils.py b/qutebrowser/commands/utils.py index a0a65674d..f3a3718a7 100644 --- a/qutebrowser/commands/utils.py +++ b/qutebrowser/commands/utils.py @@ -37,8 +37,8 @@ class CommandParser(QObject): args = [] error = pyqtSignal(str) # Emitted if there's an error - def parse(self, text): - """Parses a command and runs its handler""" + def _parse(self, text): + """Parses a command""" self.text = text parts = self.text.strip().split(maxsplit=1) cmdstr = parts[0] @@ -57,29 +57,29 @@ class CommandParser(QObject): self.cmd = cmd self.args = args - def check(self): + def _check(self): try: self.cmd.check(self.args) except ArgumentCountError: self.error.emit("{}: invalid argument count".format(self.cmd)) raise - def run(self, count=None): + def _run(self, count=None): if count is not None: self.cmd.run(self.args, count=count) else: self.cmd.run(self.args) - def parse_check_run(self, text, count=None, ignore_exc=True): + def run(self, text, count=None, ignore_exc=True): try: - self.parse(text) - self.check() + self._parse(text) + self._check() except (ArgumentCountError, NoSuchCommandError): if ignore_exc: return else: raise - self.run(count=count) + self._run(count=count) class Command(QObject): """Base skeleton for a command. See the module help for