summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2011-10-16 01:23:13 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2011-10-16 01:23:13 +0100
commitce805a14602daa3bcd38c8f20223f18bb4bc546e (patch)
treefe439a801b6f7801158ec3f9ce1a5e3e059f0598 /alot
parent0d9535b94187380a315c62ffc668722a6c7cb167 (diff)
helpstrings and pep8
Diffstat (limited to 'alot')
-rw-r--r--alot/commands/__init__.py8
-rw-r--r--alot/commands/envelope.py15
-rw-r--r--alot/commands/globals.py34
-rw-r--r--alot/commands/taglist.py2
-rw-r--r--alot/commands/thread.py33
5 files changed, 44 insertions, 48 deletions
diff --git a/alot/commands/__init__.py b/alot/commands/__init__.py
index 95a5ea9d..b5886754 100644
--- a/alot/commands/__init__.py
+++ b/alot/commands/__init__.py
@@ -34,6 +34,7 @@ COMMANDS = {
'global': {},
}
+
def lookup_command(cmdname, mode):
"""returns commandclass, argparser and forcedparams
for `cmdname` in `mode`"""
@@ -44,9 +45,11 @@ def lookup_command(cmdname, mode):
else:
return None, None, None
+
def lookup_parser(cmdname, mode):
return lookup_command(cmdname, mode)[1]
+
class CommandParseError(Exception):
pass
@@ -72,11 +75,12 @@ class registerCommand(object):
def __call__(self, klass):
argparser = CommandArgumentParser(description=self.help,
prog=self.name, add_help=False)
- for args,kwargs in self.arguments:
+ for args, kwargs in self.arguments:
argparser.add_argument(*args, **kwargs)
COMMANDS[self.mode][self.name] = (klass, argparser, self.forced)
return klass
+
def commandfactory(cmdline, mode='global'):
# split commandname and parameters
if not cmdline:
@@ -98,7 +102,7 @@ def commandfactory(cmdline, mode='global'):
cmdname = 'shellescape'
# get class, argparser and forced parameter
- (cmdclass, parser, forcedparms) = lookup_command(cmdname,mode)
+ (cmdclass, parser, forcedparms) = lookup_command(cmdname, mode)
if cmdclass is None:
msg = 'unknown command: %s' % cmdname
logging.debug(msg)
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py
index b575b471..c5f5c96a 100644
--- a/alot/commands/envelope.py
+++ b/alot/commands/envelope.py
@@ -21,10 +21,8 @@ from alot.commands.globals import EnvelopeOpenCommand
MODE = 'envelope'
-@registerCommand(MODE, 'attach',
- help='attach files to the mail', arguments=[
- (['path'], {'help':'file(s) to attach (accepts wildcads)'})]
-)
+@registerCommand(MODE, 'attach', help='attach files to the mail', arguments=[
+ (['path'], {'help':'file(s) to attach (accepts wildcads)'})])
class EnvelopeAttachCommand(Command):
def __init__(self, path=None, mail=None, **kwargs):
Command.__init__(self, **kwargs)
@@ -53,11 +51,9 @@ class EnvelopeAttachCommand(Command):
ui.current_buffer.set_email(msg)
-@registerCommand(MODE, 'refine',
- help='prompt to change the value of a header',
+@registerCommand(MODE, 'refine', help='prompt to change the value of a header',
arguments=[
- (['key'], {'help':'header to refine'})]
-)
+ (['key'], {'help':'header to refine'})])
class EnvelopeRefineCommand(Command):
def __init__(self, key='', **kwargs):
@@ -209,8 +205,7 @@ class EnvelopeEditCommand(Command):
@registerCommand(MODE, 'set', help='set header value', arguments=[
(['--replace'], {'action': 'store_true', 'help':'remove old value'}),
(['key'], {'help':'header to refine'}),
- (['value'], {'nargs':'+', 'help':'value'})]
-)
+ (['value'], {'nargs':'+', 'help':'value'})])
class EnvelopeSetCommand(Command):
"""sets header fields of mail open in envelope buffer"""
diff --git a/alot/commands/globals.py b/alot/commands/globals.py
index 020d1dfc..28f028f1 100644
--- a/alot/commands/globals.py
+++ b/alot/commands/globals.py
@@ -34,10 +34,8 @@ class ExitCommand(Command):
ui.exit()
-@registerCommand(MODE, 'search',
- help='open a new search buffer', arguments=[
- (['query'], {'nargs':'*', 'default':'', 'help':'search string'})]
-)
+@registerCommand(MODE, 'search', help='open a new search buffer', arguments=[
+ (['query'], {'nargs':'*', 'default':'', 'help':'search string'})])
class SearchCommand(Command):
def __init__(self, query, **kwargs):
self.query = ' '.join(query)
@@ -64,8 +62,7 @@ class SearchCommand(Command):
@registerCommand(MODE, 'prompt', help='starts commandprompt', arguments=[
- (['startwith'], {'nargs':'?', 'default':'', 'help':'initial content of commandprompt'})]
-)
+ (['startwith'], {'nargs':'?', 'default':'', 'help':'initial content'})])
class PromptCommand(Command):
def __init__(self, startwith='', **kwargs):
self.startwith = startwith
@@ -82,10 +79,9 @@ class RefreshCommand(Command):
ui.update()
-@registerCommand(MODE, 'shellescape',help='calls external command',
- arguments=[
- (['cmd'], {'help':'command line to execute'})]
-)
+@registerCommand(MODE, 'shellescape', arguments=[
+ (['cmd'], {'help':'command line to execute'})],
+ help='calls external command')
class ExternalCommand(Command):
def __init__(self, cmd, path=None, spawn=False, refocus=True,
in_thread=False, on_success=None, **kwargs):
@@ -155,7 +151,7 @@ class ExternalCommand(Command):
#@registerCommand(MODE, 'edit', arguments=[
# (['--nospawn'], {'action': 'store_true', 'help':'spawn '}), #todo
-# (['path'], {'help':'file to edit'})]
+# (['path'], {'help':'file to edit'})]
#]
#)
class EditCommand(ExternalCommand):
@@ -277,11 +273,12 @@ class FlushCommand(Command):
ui.update()
return
+
#todo choices
-@registerCommand(MODE, 'help',
- help='display help for a command. Use \'bindings\' to display \
- all keybings interpreted in current mode.', arguments=[
- (['commandname'], {'help':'command or \'bindings\''})]
+@registerCommand(MODE, 'help', arguments=[
+ (['commandname'], {'help':'command or \'bindings\''})],
+ help='display help for a command. Use \'bindings\' to\
+ display all keybings interpreted in current mode.',
)
class HelpCommand(Command):
def __init__(self, commandname='', **kwargs):
@@ -338,8 +335,7 @@ class HelpCommand(Command):
if parser:
ui.notify(parser.format_help())
else:
- ui.notify('command %s not known in mode %s' % (self.commandname,
- ui.mode))
+ ui.notify('command not known: %s' % self.commandname)
@registerCommand(MODE, 'compose', help='compose a new email',
@@ -374,7 +370,6 @@ class ComposeCommand(Command):
if bcc:
self.mail['Bcc'] = encode_header('Bcc', ','.join(bcc))
-
@defer.inlineCallbacks
def apply(self, ui):
# TODO: fill with default header (per account)
@@ -430,8 +425,7 @@ class ComposeCommand(Command):
@registerCommand(MODE, 'move', help='move focus', arguments=[
- (['key'], {'nargs':'+', 'help':'direction'})]
-)
+ (['key'], {'nargs':'+', 'help':'direction'})])
@registerCommand(MODE, 'cancel', help='send cancel event',
forced={'key': 'cancel'})
@registerCommand(MODE, 'select', help='send select event',
diff --git a/alot/commands/taglist.py b/alot/commands/taglist.py
index c551b72f..fd8a52d8 100644
--- a/alot/commands/taglist.py
+++ b/alot/commands/taglist.py
@@ -4,7 +4,7 @@ from alot.commands.globals import SearchCommand
MODE = 'taglist'
-@registerCommand(MODE, 'select', {})
+@registerCommand(MODE, 'select', help='open search for selected tag')
class TaglistSelectCommand(Command):
def apply(self, ui):
tagstring = ui.current_buffer.get_selected_tag()
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index 53b25c58..c3e11a5a 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -21,10 +21,9 @@ MODE = 'thread'
@registerCommand(MODE, 'reply', arguments=[
- (['--all'], {'action':'store_true', 'help':'reply to all'})]
-)
+ (['--all'], {'action':'store_true', 'help':'reply to all'})],
+ help='reply to currently selected message')
class ReplyCommand(Command):
- """format reply for currently selected message and open envelope for it"""
def __init__(self, message=None, all=False, **kwargs):
"""
:param message: the original message to reply to
@@ -129,8 +128,8 @@ class ReplyCommand(Command):
@registerCommand(MODE, 'forward', arguments=[
- (['--attach'], {'action':'store_true', 'help':'attach original mail'})]
-)
+ (['--attach'], {'action':'store_true', 'help':'attach original mail'})],
+ help='forward currently selected message')
class ForwardCommand(Command):
def __init__(self, message=None, attach=True, **kwargs):
"""
@@ -200,9 +199,11 @@ class ForwardCommand(Command):
@registerCommand(MODE, 'fold', forced={'visible': False}, arguments=[
- (['--all'], {'action': 'store_true', 'help':'fold all messages'})])
+ (['--all'], {'action': 'store_true', 'help':'fold all messages'})],
+ help='fold message(s)')
@registerCommand(MODE, 'unfold', forced={'visible': True}, arguments=[
- (['--all'], {'action': 'store_true', 'help':'unfold all messages'})])
+ (['--all'], {'action': 'store_true', 'help':'unfold all messages'})],
+ help='unfold message(s)')
class FoldMessagesCommand(Command):
def __init__(self, all=False, visible=None, **kwargs):
self.all = all
@@ -229,7 +230,8 @@ class FoldMessagesCommand(Command):
widget.fold(visible=False)
-@registerCommand(MODE, 'toggleheaders')
+@registerCommand(MODE, 'toggleheaders',
+ help='toggle display of all headers')
class ToggleHeaderCommand(Command):
def apply(self, ui):
msgw = ui.current_buffer.get_selection()
@@ -237,16 +239,17 @@ class ToggleHeaderCommand(Command):
@registerCommand(MODE, 'pipeto', arguments=[
+ (['cmd'], {'help':'shellcommand to pipe to'}),
(['--all'], {'action': 'store_true', 'help':'pass all messages'}),
(['--separately'], {'action': 'store_true',
- 'help':'call command once for each message'})]
-)
+ 'help':'call command once for each message'})],
+ help='pipe message(s) to stdin of a shellcommand')
class PipeCommand(Command):
- def __init__(self, command, all=False, separately=False,
+ def __init__(self, cmd, all=False, separately=False,
noop_msg='no command specified', confirm_msg='',
done_msg='done', **kwargs):
Command.__init__(self, **kwargs)
- self.cmd = command
+ self.cmd = cmd
self.whole_thread = all
self.separately = separately
self.noop_msg = noop_msg
@@ -296,7 +299,7 @@ class PipeCommand(Command):
(['--all'], {'action': 'store_true', 'help':'print all messages'}),
(['--separately'], {'action': 'store_true',
'help':'call print command once for each message'})]
-)
+ help='print message(s)')
class PrintCommand(PipeCommand):
def __init__(self, all=False, separately=False, **kwargs):
# get print command
@@ -321,8 +324,8 @@ class PrintCommand(PipeCommand):
@registerCommand(MODE, 'save', arguments=[
(['--all'], {'action': 'store_true', 'help':'save all attachments'}),
- (['path'], {'nargs':'?', 'help':'path to save to'})]
-)
+ (['path'], {'nargs':'?', 'help':'path to save to'})],
+ help='save attachment(s)')
class SaveAttachmentCommand(Command):
def __init__(self, all=False, path=None, **kwargs):
Command.__init__(self, **kwargs)