summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2017-08-31 15:19:15 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2017-09-01 15:33:15 +0100
commit134d791f94dec9bf06b98a9881495a435c191bd3 (patch)
tree598cb50b34a1e8346c114dbf50c0a013cb3d5f48
parent0df1c905aee10308069d9db9e396714feabc4ce4 (diff)
pep8 fixes
This mostly shortens lines down to <=79 chars and fixes some other small things I found using the pep8 tool.
-rw-r--r--alot/account.py10
-rw-r--r--alot/addressbook/abook.py3
-rw-r--r--alot/commands/__init__.py1
-rw-r--r--alot/commands/envelope.py9
-rw-r--r--alot/commands/globals.py9
-rw-r--r--alot/crypto.py3
-rw-r--r--alot/db/manager.py3
-rw-r--r--alot/db/message.py3
-rw-r--r--alot/settings/manager.py12
-rw-r--r--alot/settings/utils.py1
-rw-r--r--alot/utils/cached_property.py48
-rw-r--r--alot/widgets/globals.py4
-rw-r--r--alot/widgets/search.py5
13 files changed, 61 insertions, 50 deletions
diff --git a/alot/account.py b/alot/account.py
index e561f0c9..ca3fc375 100644
--- a/alot/account.py
+++ b/alot/account.py
@@ -73,8 +73,8 @@ class Address(object):
"""
def __init__(self, user, domain, case_sensitive=False):
- assert isinstance(user, unicode), 'Username must be unicode not bytes'
- assert isinstance(domain, unicode), 'Domain name must be unicode not bytes'
+ assert isinstance(user, unicode), 'Username must be unicode'
+ assert isinstance(domain, unicode), 'Domain name must be unicode'
self.username = user
self.domainname = domain
self.case_sensitive = case_sensitive
@@ -89,7 +89,7 @@ class Address(object):
:returns: An account from the given arguments
:rtype: :class:`Account`
"""
- assert isinstance(address, unicode), 'address must be unicode not bytes'
+ assert isinstance(address, unicode), 'address must be unicode'
username, domainname = address.split(u'@')
return cls(username, domainname, case_sensitive=case_sensitive)
@@ -140,12 +140,12 @@ class Address(object):
def __eq__(self, other):
if not isinstance(other, (Address, basestring)):
- raise TypeError('Cannot compare Address to any but Address or basestring')
+ raise TypeError('Address must be compared to Address or basestring')
return self.__cmp(other, operator.eq)
def __ne__(self, other):
if not isinstance(other, (Address, basestring)):
- raise TypeError('Cannot compare Address to any but Address or basestring')
+ raise TypeError('Address must be compared to Address or basestring')
# != is the only rich comparitor that cannot be implemented using 'and'
# in self.__cmp, so it's implemented as not ==.
return not self.__cmp(other, operator.eq)
diff --git a/alot/addressbook/abook.py b/alot/addressbook/abook.py
index b620fbac..41b5103e 100644
--- a/alot/addressbook/abook.py
+++ b/alot/addressbook/abook.py
@@ -16,7 +16,8 @@ class AbookAddressBook(AddressBook):
:type path: str
"""
AddressBook.__init__(self, **kwargs)
- DEFAULTSPATH = os.path.join(os.path.dirname(__file__), '..', 'defaults')
+ DEFAULTSPATH = os.path.join(os.path.dirname(__file__), '..',
+ 'defaults')
self._spec = os.path.join(DEFAULTSPATH, 'abook_contacts.spec')
path = os.path.expanduser(path)
self._config = read_config(path, self._spec)
diff --git a/alot/commands/__init__.py b/alot/commands/__init__.py
index 0638926a..bcd27c07 100644
--- a/alot/commands/__init__.py
+++ b/alot/commands/__init__.py
@@ -34,6 +34,7 @@ class CommandCanceled(Exception):
"""
pass
+
COMMANDS = {
'search': {},
'envelope': {},
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py
index 4d2963ee..fb2d0b7a 100644
--- a/alot/commands/envelope.py
+++ b/alot/commands/envelope.py
@@ -124,9 +124,8 @@ class SaveCommand(Command):
return
if account.draft_box is None:
- ui.notify(
- 'abort: account <%s> has no draft_box set.' % envelope.get('From'),
- priority='error')
+ msg = 'abort: Account for {} has no draft_box'
+ ui.notify(msg.format(account.address), priority='error')
return
mail = envelope.construct_mail()
@@ -511,8 +510,8 @@ class SignCommand(Command):
return
if not acc.gpg_key:
envelope.sign = False
- ui.notify('Account for {} has no gpg key'.format(acc.address),
- priority='error')
+ msg = 'Account for {} has no gpg key'
+ ui.notify(msg.format(acc.address), priority='error')
return
envelope.sign_key = acc.gpg_key
else:
diff --git a/alot/commands/globals.py b/alot/commands/globals.py
index 565bd742..57ddfcb6 100644
--- a/alot/commands/globals.py
+++ b/alot/commands/globals.py
@@ -78,7 +78,8 @@ class ExitCommand(Command):
if ui.db_was_locked:
msg = 'Database locked. Exit without saving?'
- if (yield ui.choice(msg, msg_position='left', cancel='no')) == 'no':
+ response = yield ui.choice(msg, msg_position='left', cancel='no')
+ if response == 'no':
return
ui.exit()
@@ -855,7 +856,8 @@ class ComposeCommand(Command):
self.envelope.sign = account.sign_by_default
self.envelope.sign_key = account.gpg_key
else:
- msg = 'Cannot find gpg key for account {}'.format(account.address)
+ msg = 'Cannot find gpg key for account {}'
+ msg = msg.format(account.address)
logging.warning(msg)
ui.notify(msg, priority='error')
@@ -910,7 +912,8 @@ class ComposeCommand(Command):
logging.debug("Trying to encrypt message because "
"account.encrypt_by_default=%s",
account.encrypt_by_default)
- yield set_encrypt(ui, self.envelope, block_error=self.encrypt, signed_only=True)
+ yield set_encrypt(ui, self.envelope, block_error=self.encrypt,
+ signed_only=True)
else:
logging.debug("No encryption by default, encrypt_by_default=%s",
account.encrypt_by_default)
diff --git a/alot/crypto.py b/alot/crypto.py
index f3dd6d11..6e3e8fa6 100644
--- a/alot/crypto.py
+++ b/alot/crypto.py
@@ -152,7 +152,8 @@ def detached_signature_for(plaintext_str, keys):
"""
ctx = gpg.core.Context(armor=True)
ctx.signers = keys
- (sigblob, sign_result) = ctx.sign(plaintext_str, mode=gpg.constants.SIG_MODE_DETACH)
+ (sigblob, sign_result) = ctx.sign(plaintext_str,
+ mode=gpg.constants.SIG_MODE_DETACH)
return sign_result.signatures, sigblob
diff --git a/alot/db/manager.py b/alot/db/manager.py
index e592da65..6add2b7c 100644
--- a/alot/db/manager.py
+++ b/alot/db/manager.py
@@ -377,7 +377,8 @@ class DBManager(object):
:param sort: Sort order. one of ['oldest_first', 'newest_first',
'message_id', 'unsorted']
:type query: str
- :param exclude_tags: Tags to exclude by default unless included in the search
+ :param exclude_tags: Tags to exclude by default unless included in the
+ search
:type exclude_tags: list of str
:returns: a pipe together with the process that asynchronously
writes to it.
diff --git a/alot/db/message.py b/alot/db/message.py
index d07bd283..9d7437eb 100644
--- a/alot/db/message.py
+++ b/alot/db/message.py
@@ -116,8 +116,7 @@ class Message(object):
def get_tags(self):
"""returns tags attached to this message as list of strings"""
- l = sorted(self._tags)
- return l
+ return sorted(self._tags)
def get_thread(self):
"""returns the :class:`~alot.db.Thread` this msg belongs to"""
diff --git a/alot/settings/manager.py b/alot/settings/manager.py
index 6c9e80fe..ed390e78 100644
--- a/alot/settings/manager.py
+++ b/alot/settings/manager.py
@@ -25,7 +25,8 @@ from .theme import Theme
DEFAULTSPATH = os.path.join(os.path.dirname(__file__), '..', 'defaults')
-DATA_DIRS = os.environ.get('XDG_DATA_DIRS', '/usr/local/share:/usr/share').split(':')
+DATA_DIRS = os.environ.get('XDG_DATA_DIRS',
+ '/usr/local/share:/usr/share').split(':')
class SettingsManager(object):
@@ -37,8 +38,10 @@ class SettingsManager(object):
:param notmuch_rc: path to notmuch's config file
:type notmuch_rc: str
"""
- assert alot_rc is None or (isinstance(alot_rc, basestring) and os.path.exists(alot_rc))
- assert notmuch_rc is None or (isinstance(notmuch_rc, basestring) and os.path.exists(notmuch_rc))
+ assert alot_rc is None or (isinstance(alot_rc, basestring) and
+ os.path.exists(alot_rc))
+ assert notmuch_rc is None or (isinstance(notmuch_rc, basestring) and
+ os.path.exists(notmuch_rc))
self.hooks = None
self._mailcaps = mailcap.getcaps()
self._notmuchconfig = None
@@ -62,7 +65,8 @@ class SettingsManager(object):
Implementation Detail: this is the same code called by the constructor
to set bindings at alot startup.
"""
- self._bindings = ConfigObj(os.path.join(DEFAULTSPATH, 'default.bindings'))
+ self._bindings = ConfigObj(os.path.join(DEFAULTSPATH,
+ 'default.bindings'))
self.read_notmuch_config()
self.read_config()
diff --git a/alot/settings/utils.py b/alot/settings/utils.py
index ea56b264..d87157c3 100644
--- a/alot/settings/utils.py
+++ b/alot/settings/utils.py
@@ -9,6 +9,7 @@ from urwid import AttrSpec
from .errors import ConfigError
+
def read_config(configpath=None, specpath=None, checks=None):
"""
get a (validated) config object for given config file path.
diff --git a/alot/utils/cached_property.py b/alot/utils/cached_property.py
index e6187283..680cd6f4 100644
--- a/alot/utils/cached_property.py
+++ b/alot/utils/cached_property.py
@@ -1,34 +1,34 @@
# verbatim from werkzeug.utils.cached_property
#
-#Copyright (c) 2014 by the Werkzeug Team, see AUTHORS for more details.
+# Copyright (c) 2014 by the Werkzeug Team, see AUTHORS for more details.
#
-#Redistribution and use in source and binary forms, with or without
-#modification, are permitted provided that the following conditions are
-#met:
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
#
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following
+# disclaimer in the documentation and/or other materials provided
+# with the distribution.
#
-# * The names of the contributors may not be used to endorse or
-# promote products derived from this software without specific
-# prior written permission.
+# * The names of the contributors may not be used to endorse or
+# promote products derived from this software without specific
+# prior written permission.
#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-#OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
_missing = object()
diff --git a/alot/widgets/globals.py b/alot/widgets/globals.py
index 6ce29827..253999e7 100644
--- a/alot/widgets/globals.py
+++ b/alot/widgets/globals.py
@@ -86,8 +86,8 @@ class CompleteEdit(urwid.Edit):
The interpretation of some keypresses is hard-wired:
:enter: calls 'on_exit' callback with current value
- :esc/ctrl g: calls 'on_exit' with value `None`, which can be interpreted
- as cancelation
+ :esc/ctrl g: calls 'on_exit' with value `None`, which can be
+ interpreted as cancelation
:tab: calls the completer and tabs forward in the result list
:shift tab: tabs backward in the result list
:up/down: move in the local input history
diff --git a/alot/widgets/search.py b/alot/widgets/search.py
index 905887cc..446a8964 100644
--- a/alot/widgets/search.py
+++ b/alot/widgets/search.py
@@ -115,8 +115,9 @@ class ThreadlineWidget(urwid.AttrMap):
if self.thread:
fallback_normal = struct[name]['normal']
fallback_focus = struct[name]['focus']
- tag_widgets = sorted(TagWidget(t, fallback_normal, fallback_focus)
- for t in self.thread.get_tags())
+ tag_widgets = sorted(
+ TagWidget(t, fallback_normal, fallback_focus)
+ for t in self.thread.get_tags())
else:
tag_widgets = []
cols = []