diff options
Diffstat (limited to 'asciifarm/client')
| -rw-r--r-- | asciifarm/client/commandhandler.py | 19 | ||||
| -rw-r--r-- | asciifarm/client/inputhandler.py | 5 | ||||
| -rw-r--r-- | asciifarm/client/loaders.py | 4 |
3 files changed, 15 insertions, 13 deletions
diff --git a/asciifarm/client/commandhandler.py b/asciifarm/client/commandhandler.py index db9f625..ca72b68 100644 --- a/asciifarm/client/commandhandler.py +++ b/asciifarm/client/commandhandler.py @@ -51,17 +51,16 @@ class CommandHandler: } def execute(self, action): - try: - if isinstance(action[0], str): - command = action[0] - if command in self.commands: - self.commands[command](*action[1:]) - else: - raise InvalidCommandException("Invalid command '{}'".format(command)) + if action is None: + return + if isinstance(action[0], str): + command = action[0] + if command in self.commands: + self.commands[command](*action[1:]) else: - raise Exception("Command should be a string") - except Exception as e: - self.log(e) + raise InvalidCommandException("Invalid command '{}'".format(command)) + else: + raise Exception("Command should be a string") # Commands diff --git a/asciifarm/client/inputhandler.py b/asciifarm/client/inputhandler.py index 8d99c40..850e890 100644 --- a/asciifarm/client/inputhandler.py +++ b/asciifarm/client/inputhandler.py @@ -35,7 +35,10 @@ class InputHandler: else: try: command, _sep, arg = message[1:].partition(' ') - self.commandHandler.execute([command, arg]) + try: + self.commandHandler.execute([command, arg]) + except Exception as e: + self.log(e) except InvalidCommandException as e: self.client.log(", ".join(e.args)) else: diff --git a/asciifarm/client/loaders.py b/asciifarm/client/loaders.py index 0b4c5b7..8330e0e 100644 --- a/asciifarm/client/loaders.py +++ b/asciifarm/client/loaders.py @@ -23,7 +23,7 @@ def loadKeybindings(name): for ftemplate in data.get("templates", []): if ftemplate.partition(os.sep)[0] in {".", ".."}: ftemplate = os.path.relpath(ftemplate, fname) - template = loadKeyBindings(ftemplate) + template = loadKeybindings(ftemplate) bindings.update(template.get("actions", {})) help = template.get("help", help) bindings.update(data.get("actions", {})) @@ -31,7 +31,7 @@ def loadKeybindings(name): return {"actions": bindings, "help": help} -standardCharFiles = {name, os.path.join(charmapPath, file) for name, file in { +standardCharFiles = {name: os.path.join(charmapPath, file) for name, file in { "default": "default.json", "fullwith": "fullwidth.json", "fw": "fullwidth.json", |
