diff options
author | pazz <patricktotzke@gmail.com> | 2011-07-16 20:35:42 +0100 |
---|---|---|
committer | pazz <patricktotzke@gmail.com> | 2011-07-16 20:35:42 +0100 |
commit | 7ba41d110e849c3fd363cb5ef02542cfa48ceec6 (patch) | |
tree | e8d41ee5c0f5a78b7722ef45ccce9d89c79d3d77 /alot/commands.py | |
parent | ea54d5a7bcedc2710f605ef4b7b8ecfdb23c0e22 (diff) |
cleanup commands (removed factory)
Diffstat (limited to 'alot/commands.py')
-rw-r--r-- | alot/commands.py | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/alot/commands.py b/alot/commands.py index 653cf93f..a78c2579 100644 --- a/alot/commands.py +++ b/alot/commands.py @@ -444,99 +444,3 @@ class RefineSearchPromptCommand(Command): sbuffer = ui.current_buffer sbuffer.rebuild() ui.update() - -commands = { - 'bufferlist': (OpenBufferListCommand, {}), - 'buffer close': (BufferCloseCommand, {}), - 'buffer next': (BufferFocusCommand, {'offset': 1}), - 'buffer refresh': (RefreshCommand, {}), - 'buffer previous': (BufferFocusCommand, {'offset': -1}), - 'exit': (ExitCommand, {}), - 'flush': (FlushCommand, {}), - 'pyshell': (PythonShellCommand, {}), - 'search': (SearchCommand, {}), - 'shellescape': (ExternalCommand, {}), - 'taglist': (TagListCommand, {}), - 'edit': (EditCommand, {}), - - 'buffer_focus': (BufferFocusCommand, {}), - 'compose': (ComposeCommand, {}), - 'open_thread': (OpenThreadCommand, {}), - 'open_envelope': (OpenEnvelopeCommand, {}), - 'search prompt': (SearchPromptCommand, {}), - 'refine_search_prompt': (RefineSearchPromptCommand, {}), - 'send': (SendMailCommand, {}), - 'thread_tag_prompt': (ThreadTagPromptCommand, {}), - 'toggle_thread_tag': (ToggleThreadTagCommand, {'tag': 'inbox'}), - } - - -def factory(cmdname, **kwargs): - if cmdname in commands: - (cmdclass, parms) = commands[cmdname] - parms = parms.copy() - parms.update(kwargs) - for (key, value) in kwargs.items(): - if callable(value): - parms[key] = value() - else: - parms[key] = value - - parms['prehook'] = get_hook('pre_' + cmdname) - parms['posthook'] = get_hook('post_' + cmdname) - - logging.debug('cmd parms %s' % parms) - return cmdclass(**parms) - else: - logging.error('there is no command %s' % cmdname) - - -aliases = {'bc': 'buffer close', - 'bn': 'buffer next', - 'bp': 'buffer previous', - 'br': 'buffer refresh', - 'refresh': 'buffer refresh', - 'ls': 'bufferlist', - 'quit': 'exit', -} - - -def interpret(cmdline): - if not cmdline: - return None - logging.debug(cmdline + '"') - args = cmdline.strip().split(' ', 1) - cmd = args[0] - params = args[1:] - - # unfold aliases - if cmd in aliases: - cmd = aliases[cmd] - - # buffer commands depend on first parameter only - if cmd == 'buffer' and (params) == 1: - cmd = cmd + params[0] - # allow to shellescape without a space after '!' - if cmd.startswith('!'): - params = cmd[1:] + ''.join(params) - cmd = 'shellescape' - - if not params: - if cmd in ['exit', 'flush', 'pyshell', 'taglist', 'buffer close', - 'buffer next', 'buffer previous', 'buffer refresh', - 'bufferlist']: - return factory(cmd) - else: - return None - else: - if cmd == 'search': - return factory(cmd, query=params[0]) - elif cmd == 'shellescape': - return factory(cmd, commandstring=params) - elif cmd == 'edit': - filepath = params[0] - if os.path.isfile(filepath): - return factory(cmd, path=filepath) - - else: - return None |