diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2013-03-16 17:39:56 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2013-03-16 17:39:56 +0000 |
commit | d3c1880a60ddd8ded397d92cddf310a948b97fdc (patch) | |
tree | 7835ba12b1ad9a345c20be46baeda72b8c2a7549 /alot | |
parent | d811fd566e82f4df85456f5639ab8aae7f517531 (diff) |
pep8/pyflakes fixes
Diffstat (limited to 'alot')
-rw-r--r-- | alot/buffers.py | 16 | ||||
-rw-r--r-- | alot/commands/envelope.py | 48 | ||||
-rw-r--r-- | alot/commands/thread.py | 97 | ||||
-rw-r--r-- | alot/completion.py | 9 | ||||
-rw-r--r-- | alot/crypto.py | 5 | ||||
-rw-r--r-- | alot/db/envelope.py | 19 | ||||
-rw-r--r-- | alot/errors.py | 1 | ||||
-rw-r--r-- | alot/settings/manager.py | 6 | ||||
-rw-r--r-- | alot/settings/theme.py | 1 | ||||
-rw-r--r-- | alot/ui.py | 19 | ||||
-rw-r--r-- | alot/widgets/thread.py | 16 |
11 files changed, 126 insertions, 111 deletions
diff --git a/alot/buffers.py b/alot/buffers.py index bb502ab4..9dea1e23 100644 --- a/alot/buffers.py +++ b/alot/buffers.py @@ -142,7 +142,7 @@ class EnvelopeBuffer(Buffer): def rebuild(self): displayed_widgets = [] hidden = settings.get('envelope_headers_blacklist') - #build lines + # build lines lines = [] for (k, vlist) in self.envelope.headers.items(): if (k not in hidden) or self.all_headers: @@ -184,7 +184,7 @@ class EnvelopeBuffer(Buffer): self.header_wgt = HeadersList(lines, key_att, value_att, gaps_att) displayed_widgets.append(self.header_wgt) - #display attachments + # display attachments lines = [] for a in self.envelope.attachments: lines.append(AttachmentWidget(a, selectable=False)) @@ -245,12 +245,7 @@ class SearchBuffer(Buffer): self.proc.terminate() def rebuild(self): - if self.isinitialized: - pass - #focusposition = self.threadlist.get_focus()[1] - else: - #focusposition = 0 - self.isinitialized = True + self.isinitialized = True self.kill_filler_process() @@ -269,7 +264,6 @@ class SearchBuffer(Buffer): dbman=self.dbman) self.listbox = urwid.ListBox(self.threadlist) - #self.threadlist.set_focus(focusposition) self.body = self.listbox def get_selected_threadline(self): @@ -379,7 +373,6 @@ class ThreadBuffer(Buffer): for pos in self._tree.positions(): yield self._tree[pos] - def refresh(self): """refresh and flushe caches of Thread tree""" self.body.refresh() @@ -397,7 +390,8 @@ class ThreadBuffer(Buffer): self.body.set_focus(self._nested_tree.root) def _sanitize_position(self, pos): - return self._nested_tree._sanitize_position(pos, self._nested_tree._tree) + return self._nested_tree._sanitize_position(pos, + self._nested_tree._tree) def focus_selected_message(self): """focus the summary line of currently focussed message""" diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py index 88e7ab43..d2332fdb 100644 --- a/alot/commands/envelope.py +++ b/alot/commands/envelope.py @@ -22,14 +22,12 @@ from alot.helper import string_decode from alot.settings import settings from alot.utils.booleanaction import BooleanAction -import gpgme - MODE = 'envelope' @registerCommand(MODE, 'attach', arguments=[ - (['path'], {'help':'file(s) to attach (accepts wildcads)'})]) + (['path'], {'help': 'file(s) to attach (accepts wildcads)'})]) class AttachCommand(Command): """attach files to the mail""" def __init__(self, path=None, **kwargs): @@ -60,7 +58,7 @@ class AttachCommand(Command): @registerCommand(MODE, 'refine', arguments=[ - (['key'], {'help':'header to refine'})]) + (['key'], {'help': 'header to refine'})]) class RefineCommand(Command): """prompt to change the value of a header""" def __init__(self, key='', **kwargs): @@ -240,10 +238,10 @@ class SendCommand(Command): @registerCommand(MODE, 'edit', arguments=[ - (['--spawn'], {'action': BooleanAction, 'default':None, - 'help':'spawn editor in new terminal'}), - (['--refocus'], {'action': BooleanAction, 'default':True, - 'help':'refocus envelope after editing'})]) + (['--spawn'], {'action': BooleanAction, 'default': None, + 'help': 'spawn editor in new terminal'}), + (['--refocus'], {'action': BooleanAction, 'default': True, + 'help': 'refocus envelope after editing'})]) class EditCommand(Command): """edit mail""" def __init__(self, envelope=None, spawn=None, refocus=True, **kwargs): @@ -266,7 +264,7 @@ class EditCommand(Command): if not self.envelope: self.envelope = ui.current_buffer.envelope - #determine editable headers + # determine editable headers edit_headers = set(settings.get('edit_headers_whitelist')) if '*' in edit_headers: edit_headers = set(self.envelope.headers.keys()) @@ -332,7 +330,7 @@ class EditCommand(Command): if translate: content = translate(content, ui=ui, dbm=ui.dbman) - #write stuff to tempfile + # write stuff to tempfile old_tmpfile = None if self.envelope.tmpfile: old_tmpfile = self.envelope.tmpfile @@ -352,9 +350,9 @@ class EditCommand(Command): @registerCommand(MODE, 'set', arguments=[ - (['--append'], {'action': 'store_true', 'help':'keep previous values'}), - (['key'], {'help':'header to refine'}), - (['value'], {'nargs':'+', 'help':'value'})]) + (['--append'], {'action': 'store_true', 'help': 'keep previous values'}), + (['key'], {'help': 'header to refine'}), + (['value'], {'nargs': '+', 'help': 'value'})]) class SetCommand(Command): """set header value""" def __init__(self, key, value, append=False, **kwargs): @@ -379,7 +377,7 @@ class SetCommand(Command): @registerCommand(MODE, 'unset', arguments=[ - (['key'], {'help':'header to refine'})]) + (['key'], {'help': 'header to refine'})]) class UnsetCommand(Command): """remove header field""" def __init__(self, key, **kwargs): @@ -403,12 +401,12 @@ class ToggleHeaderCommand(Command): @registerCommand(MODE, 'sign', forced={'action': 'sign'}, arguments=[ - (['keyid'], {'nargs':argparse.REMAINDER, 'help':'which key id to use'})], + (['keyid'], {'nargs': argparse.REMAINDER, 'help': 'which key id to use'})], help='mark mail to be signed before sending') @registerCommand(MODE, 'unsign', forced={'action': 'unsign'}, help='mark mail not to be signed before sending') @registerCommand(MODE, 'togglesign', forced={'action': 'toggle'}, arguments=[ - (['keyid'], {'nargs':argparse.REMAINDER, 'help':'which key id to use'})], + (['keyid'], {'nargs': argparse.REMAINDER, 'help': 'which key id to use'})], help='toggle sign status') class SignCommand(Command): """toggle signing this email""" @@ -453,7 +451,7 @@ class SignCommand(Command): @registerCommand(MODE, 'encrypt', forced={'action': 'encrypt'}, arguments=[ - (['keyids'], {'nargs':argparse.REMAINDER, + (['keyids'], {'nargs': argparse.REMAINDER, 'help': 'keyid of the key to encrypt with'})], help='request encryption of message before sendout') @registerCommand(MODE, 'unencrypt', forced={'action': 'unencrypt'}, @@ -461,12 +459,12 @@ class SignCommand(Command): @registerCommand(MODE, 'toggleencrypt', forced={'action': 'toggleencrypt'}, arguments=[ (['keyids'], {'nargs': argparse.REMAINDER, - 'help':'keyid of the key to encrypt with'})], - help='toggle whether message should be encrypted before sendout') + 'help': 'keyid of the key to encrypt with'})], + help='toggle if message should be encrypted before sendout') @registerCommand(MODE, 'rmencrypt', forced={'action': 'rmencrypt'}, arguments=[ (['keyids'], {'nargs': argparse.REMAINDER, - 'help':'keyid of the key to encrypt with'})], + 'help': 'keyid of the key to encrypt with'})], help='do not encrypt to given recipient key') class EncryptCommand(Command): def __init__(self, action=None, keyids=None, **kwargs): @@ -520,11 +518,11 @@ class EncryptCommand(Command): if e.code == GPGCode.AMBIGUOUS_NAME: possible_keys = crypto.list_keys(hint=keyid) tmp_choices = [k.uids[0].uid for k in possible_keys] - choices = {str(len(tmp_choices) - x) : tmp_choices[x] + choices = {str(len(tmp_choices) - x): tmp_choices[x] for x in range(0, len(tmp_choices))} - keyid = yield ui.choice("This keyid was ambiguous. " + - "Which key do you want to use?", - choices, cancel=None) + keyid = yield ui.choice("ambiguous keyid! Which" + + "key do you want to use?", + choices, cancel=None) if keyid: self.encrypt_keys.append(keyid) continue @@ -534,5 +532,5 @@ class EncryptCommand(Command): envelope.encrypt_keys[crypto.hash_key(key)] = key if not envelope.encrypt_keys: envelope.encrypt = False - #reload buffer + # reload buffer ui.current_buffer.rebuild() diff --git a/alot/commands/thread.py b/alot/commands/thread.py index b361b7bf..a3eece68 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -94,9 +94,9 @@ def determine_sender(mail, action='reply'): @registerCommand(MODE, 'reply', arguments=[ - (['--all'], {'action':'store_true', 'help':'reply to all'}), - (['--spawn'], {'action': BooleanAction, 'default':None, - 'help':'open editor in new window'})]) + (['--all'], {'action': 'store_true', 'help': 'reply to all'}), + (['--spawn'], {'action': BooleanAction, 'default': None, + 'help': 'open editor in new window'})]) class ReplyCommand(Command): """reply to message""" def __init__(self, message=None, all=False, spawn=None, **kwargs): @@ -210,9 +210,9 @@ class ReplyCommand(Command): @registerCommand(MODE, 'forward', arguments=[ - (['--attach'], {'action':'store_true', 'help':'attach original mail'}), - (['--spawn'], {'action': BooleanAction, 'default':None, - 'help':'open editor in new window'})]) + (['--attach'], {'action': 'store_true', 'help': 'attach original mail'}), + (['--spawn'], {'action': BooleanAction, 'default': None, + 'help': 'open editor in new window'})]) class ForwardCommand(Command): """forward message""" def __init__(self, message=None, attach=True, spawn=None, **kwargs): @@ -351,8 +351,8 @@ class BounceMailCommand(Command): @registerCommand(MODE, 'editnew', arguments=[ - (['--spawn'], {'action': BooleanAction, 'default':None, - 'help':'open editor in new window'})]) + (['--spawn'], {'action': BooleanAction, 'default': None, + 'help': 'open editor in new window'})]) class EditNewCommand(Command): """edit message in as new""" def __init__(self, message=None, spawn=None, **kwargs): @@ -394,20 +394,22 @@ class EditNewCommand(Command): @registerCommand(MODE, 'fold', forced={'visible': False}, arguments=[ ( - ['query'], {'help':'query used to filter messages to affect', 'nargs': '*'}), ], + ['query'], {'help': 'query used to filter messages to affect', + 'nargs': '*'}), +], help='fold message(s)') @registerCommand(MODE, 'unfold', forced={'visible': True}, arguments=[ - ( - ['query'], {'help':'query used to filter messages to affect', 'nargs': '*'}), ], - help='unfold message(s)') + (['query'], {'help': 'query used to filter messages to affect', + 'nargs': '*'}), +], help='unfold message(s)') @registerCommand(MODE, 'togglesource', forced={'raw': 'toggle'}, arguments=[ - ( - ['query'], {'help':'query used to filter messages to affect', 'nargs': '*'}), ], - help='display message source') + (['query'], {'help': 'query used to filter messages to affect', + 'nargs': '*'}), +], help='display message source') @registerCommand(MODE, 'toggleheaders', forced={'all_headers': 'toggle'}, arguments=[ (['query'], { - 'help':'query used to filter messages to affect', + 'help': 'query used to filter messages to affect', 'nargs': '*'}), ], help='display all headers') @@ -457,7 +459,8 @@ class ChangeDisplaymodeCommand(Command): if self.raw == 'toggle': tbuffer.focus_selected_message() raw = not mt.display_source if self.raw == 'toggle' else self.raw - all_headers = not mt.display_all_headers if self.all_headers == 'toggle' else self.all_headers + all_headers = not mt.display_all_headers \ + if self.all_headers == 'toggle' else self.all_headers # collapse/expand depending on new 'visible' value if visible is False: @@ -483,20 +486,20 @@ class ChangeDisplaymodeCommand(Command): @registerCommand(MODE, 'pipeto', arguments=[ - (['cmd'], {'help':'shellcommand to pipe to', 'nargs': '+'}), - (['--all'], {'action': 'store_true', 'help':'pass all messages'}), - (['--format'], {'help':'output format', 'default':'raw', - 'choices':['raw', 'decoded', 'id', 'filepath']}), + (['cmd'], {'help': 'shellcommand to pipe to', 'nargs': '+'}), + (['--all'], {'action': 'store_true', 'help': 'pass all messages'}), + (['--format'], {'help': 'output format', 'default': 'raw', + 'choices': ['raw', 'decoded', 'id', 'filepath']}), (['--separately'], {'action': 'store_true', - 'help':'call command once for each message'}), + 'help': 'call command once for each message'}), (['--background'], {'action': 'store_true', - 'help':'don\'t stop the interface'}), + 'help': 'don\'t stop the interface'}), (['--add_tags'], {'action': 'store_true', - 'help':'add \'Tags\' header to the message'}), + 'help': 'add \'Tags\' header to the message'}), (['--shell'], {'action': 'store_true', - 'help':'let the shell interpret the command'}), + 'help': 'let the shell interpret the command'}), (['--notify_stdout'], {'action': 'store_true', - 'help':'display cmd\'s stdout as notification'}), + 'help': 'display cmd\'s stdout as notification'}), ], ) class PipeCommand(Command): @@ -621,7 +624,7 @@ class PipeCommand(Command): # seem to be non-blocking! proc = subprocess.Popen(self.cmd, shell=True, stdin=subprocess.PIPE, - #stdout=subprocess.PIPE, + # stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = proc.communicate(mail) logging.debug('start urwid screen') @@ -636,7 +639,7 @@ class PipeCommand(Command): @registerCommand(MODE, 'remove', arguments=[ - (['--all'], {'action': 'store_true', 'help':'remove whole thread'})]) + (['--all'], {'action': 'store_true', 'help': 'remove whole thread'})]) class RemoveCommand(Command): """remove message(s) from the index""" def __init__(self, all=False, **kwargs): @@ -680,12 +683,12 @@ class RemoveCommand(Command): @registerCommand(MODE, 'print', arguments=[ - (['--all'], {'action': 'store_true', 'help':'print all messages'}), - (['--raw'], {'action': 'store_true', 'help':'pass raw mail string'}), + (['--all'], {'action': 'store_true', 'help': 'print all messages'}), + (['--raw'], {'action': 'store_true', 'help': 'pass raw mail string'}), (['--separately'], {'action': 'store_true', - 'help':'call print command once for each message'}), + 'help': 'call print command once for each message'}), (['--add_tags'], {'action': 'store_true', - 'help':'add \'Tags\' header to the message'}), + 'help': 'add \'Tags\' header to the message'}), ], ) class PrintCommand(PipeCommand): @@ -727,8 +730,8 @@ class PrintCommand(PipeCommand): @registerCommand(MODE, 'save', arguments=[ - (['--all'], {'action': 'store_true', 'help':'save all attachments'}), - (['path'], {'nargs':'?', 'help':'path to save to'})]) + (['--all'], {'action': 'store_true', 'help': 'save all attachments'}), + (['path'], {'nargs': '?', 'help': 'path to save to'})]) class SaveAttachmentCommand(Command): """save attachment(s)""" def __init__(self, all=False, path=None, **kwargs): @@ -853,8 +856,8 @@ class OpenAttachmentCommand(Command): @registerCommand(MODE, 'move', help='move focus in current buffer', arguments=[(['movement'], { - 'nargs':argparse.REMAINDER, - 'help':'up, down, page up, page down, first'})]) + 'nargs': argparse.REMAINDER, + 'help': 'up, down, page up, page down, first'})]) class MoveFocusCommand(MoveCommand): def apply(self, ui): logging.debug(self.movement) @@ -875,7 +878,7 @@ class MoveFocusCommand(MoveCommand): tbuffer.focus_prev() else: MoveCommand.apply(self, ui) - # TODO add 'next matching' if threadbuffer stores the original query string + # TODO add 'next matching' if threadbuffer stores the original query # TODO: add next by date.. tbuffer.body.refresh() @@ -895,31 +898,35 @@ class ThreadSelectCommand(Command): @registerCommand(MODE, 'tag', forced={'action': 'add'}, arguments=[ - (['--all'], {'action': 'store_true', 'help':'tag all messages in thread'}), + (['--all'], {'action': 'store_true', + 'help': 'tag all messages in thread'}), (['--no-flush'], {'action': 'store_false', 'dest': 'flush', 'help': 'postpone a writeout to the index'}), - (['tags'], {'help':'comma separated list of tags'})], + (['tags'], {'help': 'comma separated list of tags'})], help='add tags to message(s)', ) @registerCommand(MODE, 'retag', forced={'action': 'set'}, arguments=[ - (['--all'], {'action': 'store_true', 'help':'tag all messages in thread'}), + (['--all'], {'action': 'store_true', + 'help': 'tag all messages in thread'}), (['--no-flush'], {'action': 'store_false', 'dest': 'flush', 'help': 'postpone a writeout to the index'}), - (['tags'], {'help':'comma separated list of tags'})], + (['tags'], {'help': 'comma separated list of tags'})], help='set message(s) tags.', ) @registerCommand(MODE, 'untag', forced={'action': 'remove'}, arguments=[ - (['--all'], {'action': 'store_true', 'help':'tag all messages in thread'}), + (['--all'], {'action': 'store_true', + 'help': 'tag all messages in thread'}), (['--no-flush'], {'action': 'store_false', 'dest': 'flush', 'help': 'postpone a writeout to the index'}), - (['tags'], {'help':'comma separated list of tags'})], + (['tags'], {'help': 'comma separated list of tags'})], help='remove tags from message(s)', ) @registerCommand(MODE, 'toggletags', forced={'action': 'toggle'}, arguments=[ - (['--all'], {'action': 'store_true', 'help':'tag all messages in thread'}), + (['--all'], {'action': 'store_true', + 'help': 'tag all messages in thread'}), (['--no-flush'], {'action': 'store_false', 'dest': 'flush', 'help': 'postpone a writeout to the index'}), - (['tags'], {'help':'comma separated list of tags'})], + (['tags'], {'help': 'comma separated list of tags'})], help='flip presence of tags on message(s)', ) class TagCommand(Command): diff --git a/alot/completion.py b/alot/completion.py index 5814f966..c1375a97 100644 --- a/alot/completion.py +++ b/alot/completion.py @@ -281,7 +281,7 @@ class CommandNameCompleter(Completer): self.mode = mode def complete(self, original, pos): - #TODO refine <tab> should get current querystring + # TODO refine <tab> should get current querystring commandprefix = original[:pos] logging.debug('original="%s" prefix="%s"' % (original, commandprefix)) cmdlist = commands.COMMANDS['global'].copy() @@ -349,7 +349,7 @@ class CommandCompleter(Completer): if a and not a.startswith('-'): all_optionals = False # complete optional parameter if - # 1. all arguments prior to current position are optional parameter + # 1. all arguments prior to current position are optional # 2. the parameter starts with '-' or we are at its beginning if all_optionals: myarg = arguments_until_now[-1] @@ -433,7 +433,8 @@ class CommandCompleter(Completer): # thread elif self.mode == 'thread' and cmd == 'save': res = self._pathcompleter.complete(params, localpos) - elif self.mode == 'thread' and cmd in ['fold', 'unfold', 'togglesource', + elif self.mode == 'thread' and cmd in ['fold', 'unfold', + 'togglesource', 'toggleheaders']: res = self._querycompleter.complete(params, localpos) elif self.mode == 'thread' and cmd in ['tag', 'retag', 'untag', @@ -446,7 +447,7 @@ class CommandCompleter(Completer): if self.mode == 'thread': directions += ['first', 'next', 'previous', 'last reply', 'first reply', 'parent', - 'next sibling','previous sibling'] + 'next sibling', 'previous sibling'] localcompleter = StringlistCompleter(directions) res = localcompleter.complete(params, localpos) diff --git a/alot/crypto.py b/alot/crypto.py index 3a130478..6281ecfd 100644 --- a/alot/crypto.py +++ b/alot/crypto.py @@ -67,7 +67,7 @@ def _hash_algo_name(hash_algo): else: raise GPGProblem(("Invalid hash_algo passed to hash_algo_name." " Please report this as a bug in alot."), - code=GPGCode.INVALID_HASH) + code=GPGCode.INVALID_HASH) def RFC3156_micalg_from_algo(hash_algo): @@ -127,7 +127,7 @@ def get_key(keyid, validate=False, encrypt=False, sign=False): raise GPGProblem(("More than one key found matching this filter." + " Please be more specific (use a key ID like " + "4AC8EE1D)."), - code=GPGCode.AMBIGUOUS_NAME) + code=GPGCode.AMBIGUOUS_NAME) elif e.code == gpgme.ERR_INV_VALUE or e.code == gpgme.ERR_EOF: raise GPGProblem("Can not find key for \'" + keyid + "\'.", code=GPGCode.NOT_FOUND) @@ -205,6 +205,7 @@ def hash_key(key): hash_str += tmp_key.keyid return hash_str + def validate_key(key, sign=False, encrypt=False): if key.revoked: raise GPGProblem("The key \"" + key.uids[0].uid + "\" is revoked.", diff --git a/alot/db/envelope.py b/alot/db/envelope.py index 6214df15..f61e257e 100644 --- a/alot/db/envelope.py +++ b/alot/db/envelope.py @@ -26,14 +26,16 @@ from utils import encode_header class Envelope(object): """a message that is not yet sent and still editable. - It holds references to unencoded! body text and mail headers among other things. - Envelope implements the python container API for easy access of header values. - So `e['To']`, `e['To'] = 'foo@bar.baz'` and 'e.get_all('To')' would work for - an envelope `e`.. + It holds references to unencoded! body text and mail headers among other + things. Envelope implements the python container API for easy access of + header values. So `e['To']`, `e['To'] = 'foo@bar.baz'` and + 'e.get_all('To')' would work for an envelope `e`.. """ headers = None - """dict containing the mail headers (a list of strings for each header key)""" + """ + dict containing the mail headers (a list of strings for each header key) + """ body = None """mail body as unicode string""" tmpfile = None @@ -43,8 +45,9 @@ class Envelope(object): tags = [] """tags # tags to add after successful sendout""" - def __init__(self, template=None, bodytext=u'', headers=None, attachments=[], - sign=False, sign_key=None, encrypt=False, tags=[]): + def __init__( + self, template=None, bodytext=u'', headers=None, attachments=[], + sign=False, sign_key=None, encrypt=False, tags=[]): """ :param template: if not None, the envelope will be initialised by :meth:`parsing <parse_template>` this string before @@ -56,7 +59,7 @@ class Envelope(object): :type headers: dict (str -> [unicode]) :param attachments: file attachments to include :type attachments: list of :class:`~alot.db.attachment.Attachment` - :param tags: tags to add after successful sendout and saving this message + :param tags: tags to add after successful sendout and saving this msg :type tags: list of str """ assert isinstance(bodytext, unicode) diff --git a/alot/errors.py b/alot/errors.py index a4169c3c..ce88f38e 100644 --- a/alot/errors.py +++ b/alot/errors.py @@ -2,6 +2,7 @@ # This file is released under the GNU GPL, version 3 or a later revision. # For further details see the COPYING file + class GPGCode: AMBIGUOUS_NAME = 1 NOT_FOUND = 2 diff --git a/alot/settings/manager.py b/alot/settings/manager.py index 9a74080a..67dd553c 100644 --- a/alot/settings/manager.py +++ b/alot/settings/manager.py @@ -137,7 +137,8 @@ class SettingsManager(object): raise ConfigError(msg) elif abook['type'] == 'abook': contacts_path = abook['abook_contacts_file'] - args['abook'] = AbookAddressBook(contacts_path, ignorecase=abook['ignorecase']) + args['abook'] = AbookAddressBook( + contacts_path, ignorecase=abook['ignorecase']) else: del(args['abook']) @@ -318,7 +319,8 @@ class SettingsManager(object): cand = filter(lambda x: x.startswith(prefixs), candidates) if prefix in candidates: candidates = cand + [prefix] - else: candidates = cand + else: + candidates = cand return candidates def get_keybinding(self, mode, key): diff --git a/alot/settings/theme.py b/alot/settings/theme.py index 0edf09e2..308ec660 100644 --- a/alot/settings/theme.py +++ b/alot/settings/theme.py @@ -13,6 +13,7 @@ from errors import ConfigError DEFAULTSPATH = os.path.join(os.path.dirname(__file__), '..', 'defaults') DUMMYDEFAULT = ('default',) * 6 + class Theme(object): """Colour theme""" def __init__(self, path): @@ -123,7 +123,8 @@ class UI(object): clear() logging.debug("cmdline: '%s'" % cmdline) # move keys are always passed - if cmdline in ['move up', 'move down', 'move page up', 'move page down']: + if cmdline in ['move up', 'move down', 'move page up', + 'move page down']: return [cmdline[5:]] elif not self._locked: try: @@ -145,7 +146,8 @@ class UI(object): timeout = float(settings.get('input_timeout')) if self._alarm is not None: self.mainloop.remove_alarm(self._alarm) - self._alarm = self.mainloop.set_alarm_in(timeout, fire, cmdline) + self._alarm = self.mainloop.set_alarm_in( + timeout, fire, cmdline) else: return fire(self.mainloop, cmdline) @@ -186,7 +188,8 @@ class UI(object): # store cmdline for use with 'repeat' command cmdline = cmdline.lstrip() - if not cmdline.startswith('prompt') and not cmdline.startswith('repeat'): + if not cmdline.startswith('prompt') and \ + not cmdline.startswith('repeat'): self.last_commandline = cmdline def _unhandeled_input(self, key): @@ -240,7 +243,7 @@ class UI(object): prefix = prefix + settings.get('prompt_suffix') - #set up widgets + # set up widgets leftpart = urwid.Text(prefix, align='left') editpart = CompleteEdit(completer, on_exit=select_or_cancel, edit_text=text, history=history) @@ -435,7 +438,7 @@ class UI(object): self._passall = False d.callback(text) - #set up widgets + # set up widgets msgpart = urwid.Text(message) choicespart = ChoiceWidget(choices, callback=select_or_cancel, select=select, cancel=cancel) @@ -588,7 +591,8 @@ class UI(object): def call_posthook(retval_from_apply): if cmd.posthook: logging.info('calling post-hook') - return defer.maybeDeferred(cmd.posthook, ui=self, dbm=self.dbman) + return defer.maybeDeferred(cmd.posthook, ui=self, + dbm=self.dbman) # define error handler for Failures/Exceptions # raised in cmd.apply() @@ -597,7 +601,8 @@ class UI(object): errmsg = failure.getErrorMessage() if errmsg: msg = "%s\n(check the log for details)" - self.notify(msg % failure.getErrorMessage(), priority='error') + self.notify( + msg % failure.getErrorMessage(), priority='error') # call cmd.apply def call_apply(ignored): diff --git a/alot/widgets/thread.py b/alot/widgets/thread.py index 548b392a..5d2e2bda 100644 --- a/alot/widgets/thread.py +++ b/alot/widgets/thread.py @@ -129,12 +129,12 @@ class DictList(SimpleTree): """ max_key_len = 1 structure = [] - #calc max length of key-string + # calc max length of key-string for key, value in content: if len(key) > max_key_len: max_key_len = len(key) for key, value in content: - ##todo : even/odd + # todo : even/odd keyw = ('fixed', max_key_len + 1, urwid.Text((key_attr, key))) valuew = urwid.Text((value_attr, value)) @@ -158,7 +158,8 @@ class MessageTree(CollapsibleTree): """ :param message: Messag to display :type message: alot.db.Message - :param odd: theme summary widget as if this is an odd line (in the message-pile) + :param odd: theme summary widget as if this is an odd line + (in the message-pile) :type odd: bool """ self._message = message @@ -224,7 +225,8 @@ class MessageTree(CollapsibleTree): def _get_summary(self): if self._summaryw is None: - self._summaryw = MessageSummaryWidget(self._message, even=(not self._odd)) + self._summaryw = MessageSummaryWidget( + self._message, even=(not self._odd)) return self._summaryw def _get_source(self): @@ -306,9 +308,9 @@ class MessageTree(CollapsibleTree): class ThreadTree(Tree): """ :class:`Tree` that parses a given :class:`alot.db.Thread` into a tree of - :class:`MessageTrees <MessageTree>` that display this threads individual messages. - As MessageTreess are *not* urwid widgets themself this is to be used in combination - with :class:`NestedTree` only. + :class:`MessageTrees <MessageTree>` that display this threads individual + messages. As MessageTreess are *not* urwid widgets themself this is to be + used in combination with :class:`NestedTree` only. """ def __init__(self, thread): self._thread = thread |