summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2014-08-02 18:01:57 +0200
committerPatrick Totzke <patricktotzke@gmail.com>2014-08-02 18:01:57 +0200
commit30dbe55e0281210af339a13fa6c12c7aa5167313 (patch)
treeba7c99a6f58b80163bb0a14c70a8102403cfe912
parent2a93e66df116af737c2c0da1b9132542a803c1fb (diff)
just formating (pep8 etc.)
-rw-r--r--alot/buffers.py3
-rw-r--r--alot/commands/search.py2
-rw-r--r--alot/completion.py1
-rw-r--r--alot/crypto.py30
-rw-r--r--alot/db/manager.py15
-rw-r--r--alot/db/utils.py10
-rw-r--r--alot/settings/manager.py4
-rw-r--r--alot/widgets/globals.py26
-rwxr-xr-xsetup.py48
9 files changed, 78 insertions, 61 deletions
diff --git a/alot/buffers.py b/alot/buffers.py
index 3c1bf4c1..29cfb846 100644
--- a/alot/buffers.py
+++ b/alot/buffers.py
@@ -312,7 +312,6 @@ class SearchBuffer(Buffer):
self.rebuild(reverse=True)
-
class ThreadBuffer(Buffer):
"""displays a thread as a tree of messages"""
@@ -383,7 +382,7 @@ class ThreadBuffer(Buffer):
summary_pos = (self.body.get_focus()[1][0], (0,))
cursor_on_non_summary = (focus_pos != summary_pos)
if cursor_on_non_summary:
- if not mid in self._auto_unread_dont_touch_mids:
+ if mid not in self._auto_unread_dont_touch_mids:
if 'unread' in msg.get_tags():
logging.debug('Tbuffer: removing unread')
diff --git a/alot/commands/search.py b/alot/commands/search.py
index e5307394..0001a0bd 100644
--- a/alot/commands/search.py
+++ b/alot/commands/search.py
@@ -135,7 +135,7 @@ class RetagPromptCommand(Command):
(['--all'], {'action': 'store_true', 'dest': 'allmessages', 'default':
False, 'help': 'retag all messages in search result'}),
(['tags'], {'help': 'comma separated list of tags'})],
- help='remove tags from all messages in the thread that match the current query',
+ help='remove tags from all messages in the thread that match the query',
)
@registerCommand(MODE, 'toggletags', forced={'action': 'toggle'}, arguments=[
(['--no-flush'], {'action': 'store_false', 'dest': 'flush',
diff --git a/alot/completion.py b/alot/completion.py
index b10aa7f4..75d50e0c 100644
--- a/alot/completion.py
+++ b/alot/completion.py
@@ -16,6 +16,7 @@ from alot.helper import split_commandline
from alot.addressbooks import AddressbookError
from errors import CompletionError
+
class Completer(object):
"""base class for completers"""
def complete(self, original, pos):
diff --git a/alot/crypto.py b/alot/crypto.py
index 4c74f1bf..d5931618 100644
--- a/alot/crypto.py
+++ b/alot/crypto.py
@@ -1,7 +1,6 @@
# Copyright (C) 2011-2012 Patrick Totzke <patricktotzke@gmail.com>
# This file is released under the GNU GPL, version 3 or a later revision.
# For further details see the COPYING file
-import re
import os
from cStringIO import StringIO
@@ -55,17 +54,16 @@ def RFC3156_micalg_from_algo(hash_algo):
return 'pgp-' + hash_algo.lower()
-
-
def get_key(keyid, validate=False, encrypt=False, sign=False):
"""
Gets a key from the keyring by filtering for the specified keyid, but
only if the given keyid is specific enough (if it matches multiple
keys, an exception will be thrown).
- If validate is True also make sure that returned key is not invalid, revoked
- or expired. In addition if encrypt or sign is True also validate that key is
- valid for that action. For example only keys with private key can sign.
+ If validate is True also make sure that returned key is not invalid,
+ revoked or expired. In addition if encrypt or sign is True also validate
+ that key is valid for that action. For example only keys with private key
+ can sign.
:param keyid: filter term for the keyring (usually a key ID)
:param validate: validate that returned keyid is valid
@@ -80,11 +78,11 @@ def get_key(keyid, validate=False, encrypt=False, sign=False):
validate_key(key, encrypt=encrypt, sign=sign)
except gpgme.GpgmeError as e:
if e.code == gpgme.ERR_AMBIGUOUS_NAME:
- # When we get here it means there were multiple keys returned by gpg
- # for given keyid. Unfortunately gpgme returns invalid and expired
- # keys together with valid keys. If only one key is valid for given
- # operation maybe we can still return it instead of raising
- # exception
+ # When we get here it means there were multiple keys returned by
+ # gpg for given keyid. Unfortunately gpgme returns invalid and
+ # expired keys together with valid keys. If only one key is valid
+ # for given operation maybe we can still return it instead of
+ # raising exception
keys = list_keys(hint=keyid)
valid_key = None
for k in keys:
@@ -106,9 +104,13 @@ def get_key(keyid, validate=False, encrypt=False, sign=False):
if not valid_key:
# there were multiple keys found but none of them are valid for
- # given action (we don't have private key, they are expired etc)
- raise GPGProblem("Can not find usable key for \'" + keyid + "\'.",
- code=GPGCode.NOT_FOUND)
+ # given action (we don't have private key, they are expired
+ # etc)
+ raise GPGProblem(
+ "Can not find usable key for \'" +
+ keyid +
+ "\'.",
+ code=GPGCode.NOT_FOUND)
return valid_key
elif e.code == gpgme.ERR_INV_VALUE or e.code == gpgme.ERR_EOF:
raise GPGProblem("Can not find key for \'" + keyid + "\'.",
diff --git a/alot/db/manager.py b/alot/db/manager.py
index 5450b788..2847956d 100644
--- a/alot/db/manager.py
+++ b/alot/db/manager.py
@@ -16,16 +16,16 @@ from collections import deque
from message import Message
from alot.settings import settings
from thread import Thread
-from errors import DatabaseError
-from errors import DatabaseLockedError
-from errors import DatabaseROError
-from errors import NonexistantObjectError
+from .errors import DatabaseError
+from .errors import DatabaseLockedError
+from .errors import DatabaseROError
+from .errors import NonexistantObjectError
from alot.db import DB_ENC
from alot.db.utils import is_subdir_of
-
class FillPipeProcess(multiprocessing.Process):
+
def __init__(self, it, stdout, stderr, pipe, fun=(lambda x: x)):
multiprocessing.Process.__init__(self)
self.it = it
@@ -66,6 +66,7 @@ class FillPipeProcess(multiprocessing.Process):
class DBManager(object):
+
"""
Keeps track of your index parameters, maintains a write-queue and
lets you look up threads and messages directly to the persistent wrapper
@@ -362,7 +363,7 @@ class DBManager(object):
with os.fdopen(fd) as handle:
for line in handle:
logging.debug('Worker process {0} said on {1}: {2}'.format(
- process.pid, prefix, line.rstrip()))
+ process.pid, prefix, line.rstrip()))
# spawn two threads that read from the stdout and stderr pipes
# and write anything that appears there to the log
@@ -420,7 +421,7 @@ class DBManager(object):
"""
if self.ro:
raise DatabaseROError()
- if not is_subdir_of(path,self.path):
+ if not is_subdir_of(path, self.path):
msg = 'message path %s ' % path
msg += ' is not below notmuchs '
msg += 'root path (%s)' % self.path
diff --git a/alot/db/utils.py b/alot/db/utils.py
index 40b743b9..bea7b0c6 100644
--- a/alot/db/utils.py
+++ b/alot/db/utils.py
@@ -150,7 +150,8 @@ def message_from_file(handle):
want = 'application/octet-stream'
ct = m.get_payload(1).get_content_type()
if ct != want:
- malformed = u'expected Content-Type: {0}, got: {1}'.format(want, ct)
+ malformed = u'expected Content-Type: {0}, got: {1}'.format(want,
+ ct)
if not malformed:
try:
@@ -398,11 +399,12 @@ def encode_header(key, value):
value = Header(value)
return value
+
def is_subdir_of(subpath, superpath):
- #make both absolute
+ # make both absolute
superpath = os.path.realpath(superpath)
subpath = os.path.realpath(subpath)
- #return true, if the common prefix of both is equal to directory
- #e.g. /a/b/c/d.rst and directory is /a/b, the common prefix is /a/b
+ # return true, if the common prefix of both is equal to directory
+ # e.g. /a/b/c/d.rst and directory is /a/b, the common prefix is /a/b
return os.path.commonprefix([subpath, superpath]) == superpath
diff --git a/alot/settings/manager.py b/alot/settings/manager.py
index 9aa61f87..66c8e355 100644
--- a/alot/settings/manager.py
+++ b/alot/settings/manager.py
@@ -330,7 +330,7 @@ class SettingsManager(object):
:returns: dictionaries of key-cmd for global and specific mode
:rtype: 2-tuple of dicts
"""
- globalmaps, modemaps = {},{}
+ globalmaps, modemaps = {}, {}
bindings = self._bindings
# get bindings for mode `mode`
# retain empty assignations to silence corresponding global mappings
@@ -350,7 +350,7 @@ class SettingsManager(object):
if value and value != '':
globalmaps[key] = value
# get rid of empty commands left in mode bindings
- for key in [k for k,v in modemaps.items() if not v or v=='']:
+ for key in [k for k, v in modemaps.items() if not v or v == '']:
del modemaps[key]
return globalmaps, modemaps
diff --git a/alot/widgets/globals.py b/alot/widgets/globals.py
index ada73788..50fc032f 100644
--- a/alot/widgets/globals.py
+++ b/alot/widgets/globals.py
@@ -94,9 +94,11 @@ class CompleteEdit(urwid.Edit):
:ctrl a/e: moves curser to the beginning/end of the input
:ctrl d: deletes the character under the cursor
:meta d: deletes everything from the cursor to the end of the next word
- :meta delete/backspace ctrl w: deletes everything from the cursor to the beginning of the current word
+ :meta delete/backspace ctrl w: deletes everything from the cursor to
+ the beginning of the current word
:ctrl k: deletes everything from the cursor to the end of the input
- :ctrl u: deletes everything from the cursor to the beginning of the input
+ :ctrl u: deletes everything from the cursor to the beginning of the
+ input
"""
def __init__(self, completer, on_exit,
on_error=None,
@@ -108,7 +110,8 @@ class CompleteEdit(urwid.Edit):
:type completer: alot.completion.Completer
:param on_exit: "enter"-callback that interprets the input (str)
:type on_exit: callable
- :param on_error: callback that handles :class:`completion errors <alot.errors.CompletionErrors>`
+ :param on_error: callback that handles
+ :class:`alot.errors.CompletionErrors`
:type on_error: callback
:param edit_text: initial text
:type edit_text: str
@@ -190,14 +193,14 @@ class CompleteEdit(urwid.Edit):
elif key == 'meta d':
start_pos = self.edit_pos
end_pos = self.move_to_next_word(forward=True)
- if end_pos != None:
+ if end_pos is not None:
self.edit_text = (self.edit_text[:start_pos] +
self.edit_text[end_pos:])
self.set_edit_pos(start_pos)
elif key in ('meta delete', 'meta backspace', 'ctrl w'):
end_pos = self.edit_pos
start_pos = self.move_to_next_word(forward=False)
- if start_pos != None:
+ if start_pos is not None:
self.edit_text = (self.edit_text[:start_pos] +
self.edit_text[end_pos:])
self.set_edit_pos(start_pos)
@@ -208,13 +211,13 @@ class CompleteEdit(urwid.Edit):
def move_to_next_word(self, forward=True):
if forward:
- match_iterator = re.finditer(r'(\b\W+|$)', self.edit_text,
- flags=re.UNICODE)
+ match_iterator = re.finditer(r'(\b\W+|$)', self.edit_text,
+ flags=re.UNICODE)
match_positions = [m.start() for m in match_iterator]
op = operator.gt
else:
- match_iterator = re.finditer(r'(\w+\b|^)', self.edit_text,
- flags=re.UNICODE)
+ match_iterator = re.finditer(r'(\w+\b|^)', self.edit_text,
+ flags=re.UNICODE)
match_positions = reversed([m.start() for m in match_iterator])
op = operator.lt
for pos in match_positions:
@@ -222,6 +225,7 @@ class CompleteEdit(urwid.Edit):
self.set_edit_pos(pos)
return pos
+
class HeadersList(urwid.WidgetWrap):
""" renders a pile of header values as key/value list """
def __init__(self, headerslist, key_attr, value_attr, gaps_attr=None):
@@ -250,12 +254,12 @@ class HeadersList(urwid.WidgetWrap):
def _build_lines(self, lines):
max_key_len = 1
headerlines = []
- #calc max length of key-string
+ # calc max length of key-string
for key, value in lines:
if len(key) > max_key_len:
max_key_len = len(key)
for key, value in lines:
- ##todo : even/odd
+ # todo : even/odd
keyw = ('fixed', max_key_len + 1,
urwid.Text((self.key_attr, key)))
valuew = urwid.Text((self.value_attr, value))
diff --git a/setup.py b/setup.py
index 177f6352..350bda1d 100755
--- a/setup.py
+++ b/setup.py
@@ -11,26 +11,34 @@ setup(name='alot',
author_email=alot.__author_email__,
url=alot.__url__,
license=alot.__copyright__,
- packages=['alot', 'alot.commands', 'alot.settings', 'alot.db',
- 'alot.utils', 'alot.widgets', 'alot.foreign', 'alot.foreign.urwidtrees'],
- package_data={'alot': [
- 'defaults/alot.rc.spec',
- 'defaults/notmuch.rc.spec',
- 'defaults/abook_contacts.spec',
- 'defaults/default.theme',
- 'defaults/default.bindings',
- 'defaults/config.stub',
- 'defaults/theme.spec',
- ]},
+ packages=[
+ 'alot',
+ 'alot.commands',
+ 'alot.settings',
+ 'alot.db',
+ 'alot.utils',
+ 'alot.widgets',
+ 'alot.foreign',
+ 'alot.foreign.urwidtrees'],
+ package_data={
+ 'alot': [
+ 'defaults/alot.rc.spec',
+ 'defaults/notmuch.rc.spec',
+ 'defaults/abook_contacts.spec',
+ 'defaults/default.theme',
+ 'defaults/default.bindings',
+ 'defaults/config.stub',
+ 'defaults/theme.spec',
+ ]},
scripts=['bin/alot'],
requires=[
- 'notmuch (>=0.13)',
- 'argparse (>=2.7)',
- 'urwid (>=1.1.0)',
- 'twisted (>=10.2.0)',
- 'magic',
- 'configobj (>=4.6.0)',
- 'subprocess (>=2.7)',
- 'gpgme (>=0.2)'],
+ 'notmuch (>=0.13)',
+ 'argparse (>=2.7)',
+ 'urwid (>=1.1.0)',
+ 'twisted (>=10.2.0)',
+ 'magic',
+ 'configobj (>=4.6.0)',
+ 'subprocess (>=2.7)',
+ 'gpgme (>=0.2)'],
provides='alot',
-)
+ )