diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2013-08-03 20:13:25 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2013-10-30 20:54:13 +0000 |
commit | 8627ccf20d64ef198730656c35c2431ad2b76935 (patch) | |
tree | 1ac12e1fa82919b65d92739cac6ef21bec5edb33 | |
parent | 0a11f2ace590414178c987c546f2401dfbb8376f (diff) |
docstrings for ui.appli_commandline
-rw-r--r-- | alot/ui.py | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -173,9 +173,18 @@ class UI(object): :param cmdline: command line to interpret :type cmdline: str """ + # remove initial spaces cmdline = cmdline.lstrip() - def apply_command(ignored, cmdstring, cmd): + # we pass Commands one by one to `self.apply_command`. + # To properly call them in sequence, even if they trigger asyncronous + # code (return Deferreds), these applications happen in individual + # callback functions which are then used as callback chain to some + # trivial Deferred that immediately calls its first callback. This way, + # one callback may return a Deferred and thus postpone the application + # of the next callback (and thus Command-application) + + def apply_this_command(ignored, cmdstring, cmd): logging.debug('CMDSEQ: apply %s' % str(cmdstring)) # store cmdline for use with 'repeat' command if cmd.repeatable: @@ -183,8 +192,7 @@ class UI(object): return self.apply_command(cmd, handle_error=False) # we initialize a deferred which is already triggered - # so that our callbacks will start to be called - # immediately as possible + # so that the first callbacks will be called immediately d = defer.succeed(None) # split commandline if necessary @@ -195,7 +203,7 @@ class UI(object): except CommandParseError, e: self.notify(e.message, priority='error') return - d.addCallback(apply_command, cmdstring, cmd) + d.addCallback(apply_this_command, cmdstring, cmd) return d def _unhandeled_input(self, key): |