summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2012-02-19 15:37:30 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2012-02-19 16:10:47 +0000
commit278e20ba759cc9045c9273f4e64314305f108f24 (patch)
treee4c1ff0302bf8a901d75cceeff6af1220b99cbe8
parent0b93dad9845a9a55821e1fdbb3ccafb97f265127 (diff)
pep8/pyflakes cleanup
-rw-r--r--alot/buffers.py7
-rw-r--r--alot/commands/envelope.py5
-rw-r--r--alot/commands/globals.py1
-rw-r--r--alot/commands/thread.py2
-rw-r--r--alot/completion.py5
-rw-r--r--alot/helper.py1
-rw-r--r--alot/message.py1
-rw-r--r--alot/settings.py29
-rw-r--r--alot/ui.py4
9 files changed, 26 insertions, 29 deletions
diff --git a/alot/buffers.py b/alot/buffers.py
index 43982369..3f4a6353 100644
--- a/alot/buffers.py
+++ b/alot/buffers.py
@@ -9,7 +9,6 @@ from helper import shorten_author_string
from db import NonexistantObjectError
-
class Buffer(object):
"""Abstract base class for buffers."""
@@ -71,9 +70,11 @@ class BufferlistBuffer(Buffer):
for (num, b) in enumerate(displayedbuffers):
line = widgets.BufferlineWidget(b)
if (num % 2) == 0:
- attr = settings.get_theming_attribute('bufferlist', 'results_even')
+ attr = settings.get_theming_attribute('bufferlist',
+ 'results_even')
else:
- attr = settings.get_theming_attribute('bufferlist', 'results_odd')
+ attr = settings.get_theming_attribute('bufferlist',
+ 'results_odd')
focus_att = settings.get_theming_attribute('bufferlist', 'focus')
buf = urwid.AttrMap(line, attr, focus_att)
num = urwid.Text('%3d:' % self.index_of(b))
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py
index d821d47b..8b95783b 100644
--- a/alot/commands/envelope.py
+++ b/alot/commands/envelope.py
@@ -5,7 +5,6 @@ import logging
import email
import tempfile
from twisted.internet.defer import inlineCallbacks
-from twisted.internet import threads
import datetime
from alot.account import SendingMailFailed
@@ -121,7 +120,6 @@ class SendCommand(Command):
return
frm = envelope.get('From')
sname, saddr = email.Utils.parseaddr(frm)
- omit_signature = False
# determine account to use for sending
account = settings.get_account_by_address(saddr)
@@ -218,7 +216,8 @@ class EditCommand(Command):
# call post-edit translate hook
translate = settings.get_hook('post_edit_translate')
if translate:
- template = translate(template, ui=ui, dbm=ui.dbman, config=settings)
+ template = translate(template, ui=ui, dbm=ui.dbman,
+ config=settings)
self.envelope.parse_template(template)
if self.openNew:
ui.buffer_open(buffers.EnvelopeBuffer(ui, self.envelope))
diff --git a/alot/commands/globals.py b/alot/commands/globals.py
index f5c52a1b..db944a00 100644
--- a/alot/commands/globals.py
+++ b/alot/commands/globals.py
@@ -15,7 +15,6 @@ from alot.completion import CommandLineCompleter
from alot.commands import CommandParseError
from alot.commands import commandfactory
from alot import buffers
-from alot import settings
from alot import widgets
from alot import helper
from alot.db import DatabaseLockedError
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index 2707a533..7ffb9b98 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -12,7 +12,6 @@ from alot.commands.globals import ExternalCommand
from alot.commands.globals import FlushCommand
from alot.commands.globals import ComposeCommand
from alot.commands.globals import RefreshCommand
-from alot import settings
from alot import widgets
from alot import completion
from alot.message import decode_header
@@ -21,7 +20,6 @@ from alot.message import extract_headers
from alot.message import extract_body
from alot.message import Envelope
from alot.db import DatabaseROError
-from alot.db import DatabaseError
from alot.settings import settings
MODE = 'thread'
diff --git a/alot/completion.py b/alot/completion.py
index caa13c00..e9e44226 100644
--- a/alot/completion.py
+++ b/alot/completion.py
@@ -8,6 +8,7 @@ import alot.commands as commands
from alot.buffers import EnvelopeBuffer
from alot.settings import settings
+
class Completer(object):
"""base class for completers"""
def complete(self, original, pos):
@@ -207,6 +208,7 @@ class AbooksCompleter(Completer):
returnlist.append((newtext, len(newtext)))
return returnlist
+
class ArgparseOptionCompleter(Completer):
"""completes option parameters for a given argparse.Parser"""
def __init__(self, parser):
@@ -223,7 +225,7 @@ class ArgparseOptionCompleter(Completer):
res = []
for act in self.actions:
if '=' in pref:
- optionstring = pref[:pref.rfind('=')+1]
+ optionstring = pref[:pref.rfind('=') + 1]
# get choices
if 'choices' in act.__dict__:
choices = act.choices or []
@@ -238,6 +240,7 @@ class ArgparseOptionCompleter(Completer):
return [(a, len(a)) for a in res]
+
class AccountCompleter(StringlistCompleter):
"""completes users' own mailaddresses"""
diff --git a/alot/helper.py b/alot/helper.py
index bc5dc962..bfd9e1d0 100644
--- a/alot/helper.py
+++ b/alot/helper.py
@@ -18,7 +18,6 @@ import StringIO
import logging
-
def safely_get(clb, E, on_error=''):
"""
returns result of :func:`clb` and falls back to `on_error`
diff --git a/alot/message.py b/alot/message.py
index 1557b7fa..75f204c2 100644
--- a/alot/message.py
+++ b/alot/message.py
@@ -16,7 +16,6 @@ from alot import __version__
import logging
import helper
from settings import get_mime_handler
-from settings import config
from settings import settings
from helper import string_sanitize
from helper import string_decode
diff --git a/alot/settings.py b/alot/settings.py
index f18a9ec8..aec7adfb 100644
--- a/alot/settings.py
+++ b/alot/settings.py
@@ -18,9 +18,11 @@ from ConfigParser import SafeConfigParser, ParsingError, NoOptionError
DEFAULTSPATH = os.path.join(os.path.dirname(__file__), 'defaults')
+
class ConfigError(Exception):
pass
+
def read_config(configpath=None, specpath=None):
try:
config = ConfigObj(infile=configpath, configspec=specpath,
@@ -57,7 +59,7 @@ class Theme(object):
try:
colours = int(sec)
except ValueError:
- err_msg='section %s is not an integer indicating a colour mode'
+ err_msg = 'section name %s is not a valid colour mode'
raise ConfigError(err_msg % sec)
attributes[colours] = {}
for mode in c[sec].sections:
@@ -79,7 +81,6 @@ class Theme(object):
attributes[colours][mode][themable] = att
return attributes
-
def get_attribute(self, mode, name, colourmode):
return self.attributes[colourmode][mode][name]
@@ -99,7 +100,6 @@ class SettingsManager(object):
self._accounts = self.parse_accounts(self._config)
self._accountmap = self._account_table(self._accounts)
-
def read_notmuch_config(self, path):
spec = os.path.join(DEFAULTSPATH, 'notmuch.rc.spec')
self._notmuchconfig = read_config(path, spec)
@@ -183,24 +183,24 @@ class SettingsManager(object):
def get_tagstring_representation(self, tag):
colours = int(self._config.get('colourmode'))
- default_att = self.theme.get_attribute('global', 'tag', colours)
- default_focus_att = self.theme.get_attribute('global', 'tag_focus',
- colours)
+ # default attributes: normal and focussed
+ default = self.theme.get_attribute('global', 'tag', colours)
+ default_f = self.theme.get_attribute('global', 'tag_focus', colours)
if tag in self._config['tags']:
- fg = self._config['tags'][tag]['fg'] or default_att.foreground
- bg = self._config['tags'][tag]['bg'] or default_att.background
+ fg = self._config['tags'][tag]['fg'] or default.foreground
+ bg = self._config['tags'][tag]['bg'] or default.background
normal = urwid.AttrSpec(fg, bg, colours)
- ffg = self._config['tags'][tag]['focus_fg'] or default_focus_att.foreground
- fbg = self._config['tags'][tag]['focus_bg'] or default_focus_att.background
+ ffg = self._config['tags'][tag]['focus_fg'] or default_f.foreground
+ fbg = self._config['tags'][tag]['focus_bg'] or default_f.background
focussed = urwid.AttrSpec(ffg, fbg, colours)
translated = self._config['tags'][tag]['translated'] or tag
else:
- normal = default_att
- focussed = default_focus_att
+ normal = default
+ focussed = default_f
translated = tag
- return {'normal': normal, 'focussed': focussed, 'translated': translated}
-
+ return {'normal': normal, 'focussed': focussed,
+ 'translated': translated}
def get_hook(self, key):
"""return hook (`callable`) identified by `key`"""
@@ -270,6 +270,7 @@ class SettingsManager(object):
abooks.append(a.abook)
return abooks
+
class FallbackConfigParser(SafeConfigParser):
""":class:`~ConfigParser.SafeConfigParser` that allows fallback values"""
def __init__(self):
diff --git a/alot/ui.py b/alot/ui.py
index b9de9c8c..032f627b 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -1,9 +1,7 @@
import urwid
import logging
from twisted.internet import reactor, defer
-from twisted.python.failure import Failure
-from settings import config
from settings import settings
from buffers import BufferlistBuffer
import commands
@@ -84,7 +82,7 @@ class UI(object):
self.dbman = dbman
if not colourmode:
- # needs explicit int-constructor because we used "options" in specfile
+ # explicit int-constructor because we used "options" in specfile
colourmode = int(settings.get('colourmode'))
logging.info('setup gui in %d colours' % colourmode)
self.mainframe = urwid.Frame(urwid.SolidFill())