Beispiel #1
0
 def do_menu_command(self, editor, sender):
     command = self.commands.get(sender.tag())
     if command is not None:
         try:
             command(editor, None)
         except Exception:
             log.exception("%s.execute failed", type(command).__name__)
Beispiel #2
0
 def execute(self, text):
     self.reset()
     if not text.strip():
         return
     self.failed_command = text
     editor = self.window.current_editor
     if editor is None:
         beep()
         return
     command, index = self._find_command(text)
     if command is None:
         self.message("unknown command: {}".format(text))
         return
     try:
         args = self.parser(command).parse(text, index)
     except Exception:
         msg = "parse error: {}".format(text)
         self.message(msg, exc_info=True)
         return
     finally:
         self._cached_parser = (None, None, None)
     assert args is not None, "invalid command arguments: {}".format(text)
     try:
         message = command(editor, args)
     except CommandError as err:
         self.message(err)
     except Exception:
         msg = "error in command: {} in {}".format(command.__name__, command.__module__)
         self.message(msg, exc_info=True)
     else:
         self.failed_command = None
         if not text.startswith(" "):
             self.text_commander.history.append(text)
         if message is not None:
             self.message(message, msg_type=const.INFO)