Skip to content

Commit

Permalink
Merge pull request #883 from lucc/minor
Browse files Browse the repository at this point in the history
Some minor style fixes/improvements
  • Loading branch information
lucc committed Dec 9, 2016
2 parents 3b22ecd + 03fcbc3 commit 9171f56
Show file tree
Hide file tree
Showing 33 changed files with 328 additions and 327 deletions.
6 changes: 3 additions & 3 deletions alot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def main():
args = Options()
try:
args.parseOptions() # When given no argument, parses sys.argv[1:]
except usage.UsageError, errortext:
except usage.UsageError as errortext:
print '%s' % errortext
print 'Try --help for usage details.'
sys.exit(1)
Expand Down Expand Up @@ -155,7 +155,7 @@ def main():
try:
settings.read_config(alotconfig)
settings.read_notmuch_config(notmuchconfig)
except (ConfigError, OSError, IOError), e:
except (ConfigError, OSError, IOError) as e:
sys.exit(e)

# store options given by config swiches to the settingsManager:
Expand All @@ -179,7 +179,7 @@ def main():
cmdstring += ' ' + args.subOptions.rest
else:
cmdstring = settings.get('initial_command')
except CommandParseError, e:
except CommandParseError as e:
sys.exit(e)

# set up and start interface
Expand Down
12 changes: 6 additions & 6 deletions alot/account.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# 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 mailbox
import glob
import logging
import mailbox
import os
import glob

from alot.helper import call_cmd_async
from alot.helper import split_commandstring
from .helper import call_cmd_async
from .helper import split_commandstring


class SendingMailFailed(RuntimeError):
Expand Down Expand Up @@ -119,7 +119,7 @@ def store_mail(self, mbx, mail):
message_id = mbx.add(msg)
mbx.flush()
mbx.unlock()
logging.debug('got mailbox msg id : %s' % message_id)
logging.debug('got mailbox msg id : %s', message_id)
except Exception as e:
raise StoreMailError(e)

Expand All @@ -132,7 +132,7 @@ def store_mail(self, mbx, mail):
message_id + '*')
if plist:
path = os.path.join(mbx._path, 'new', plist[0])
logging.debug('path of saved msg: %s' % path)
logging.debug('path of saved msg: %s', path)
return path

def store_sent_mail(self, mail):
Expand Down
2 changes: 1 addition & 1 deletion alot/addressbook/abook.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, path='~/.abook/addressbook', **kwargs):
self._spec = os.path.join(DEFAULTSPATH, 'abook_contacts.spec')
path = os.path.expanduser(path)
self._config = read_config(path, self._spec)
del(self._config['format'])
del self._config['format']

def get_contacts(self):
c = self._config
Expand Down
32 changes: 16 additions & 16 deletions alot/buffers.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# 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 urwid
import os
from notmuch import NotmuchError
import logging
import os

from settings import settings
import commands
from walker import PipeWalker
from helper import shorten_author_string
from db.errors import NonexistantObjectError

from alot.widgets.globals import TagWidget
from alot.widgets.globals import HeadersList
from alot.widgets.globals import AttachmentWidget
from alot.widgets.bufferlist import BufferlineWidget
from alot.widgets.search import ThreadlineWidget
from alot.widgets.thread import ThreadTree
import urwid
from urwidtrees import ArrowTree, TreeBox, NestedTree
from notmuch import NotmuchError

from .settings import settings
from . import commands
from .walker import PipeWalker
from .helper import shorten_author_string
from .db.errors import NonexistantObjectError
from .widgets.globals import TagWidget
from .widgets.globals import HeadersList
from .widgets.globals import AttachmentWidget
from .widgets.bufferlist import BufferlineWidget
from .widgets.search import ThreadlineWidget
from .widgets.thread import ThreadTree


class Buffer(object):
Expand Down Expand Up @@ -445,7 +445,7 @@ def get_focus(self):
return self.body.get_focus()

def set_focus(self, pos):
logging.debug('setting focus to %s ' % str(pos))
logging.debug('setting focus to %s ', pos)
self.body.set_focus(pos)

def focus_first(self):
Expand Down
19 changes: 9 additions & 10 deletions alot/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# 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 os
import re
import argparse
import glob
import logging
import argparse
import os
import re

from alot.settings import settings
import alot.helper
from alot.helper import split_commandstring
from ..settings import settings
from ..helper import split_commandstring, string_decode


class Command(object):
Expand Down Expand Up @@ -168,7 +167,7 @@ def commandfactory(cmdline, mode='global'):
# split commandname and parameters
if not cmdline:
return None
logging.debug('mode:%s got commandline "%s"' % (mode, cmdline))
logging.debug('mode:%s got commandline "%s"', mode, cmdline)
# allow to shellescape without a space after '!'
if cmdline.startswith('!'):
cmdline = 'shellescape \'%s\'' % cmdline[1:]
Expand All @@ -177,8 +176,8 @@ def commandfactory(cmdline, mode='global'):
args = split_commandstring(cmdline)
except ValueError as e:
raise CommandParseError(e.message)
args = map(lambda x: alot.helper.string_decode(x, 'utf-8'), args)
logging.debug('ARGS: %s' % args)
args = map(lambda x: string_decode(x, 'utf-8'), args)
logging.debug('ARGS: %s', args)
cmdname = args[0]
args = args[1:]

Expand All @@ -195,7 +194,7 @@ def commandfactory(cmdline, mode='global'):
parms = vars(parser.parse_args(args))
parms.update(forcedparms)

logging.debug('cmd parms %s' % parms)
logging.debug('cmd parms %s', parms)

# create Command
cmd = cmdclass(**parms)
Expand Down
2 changes: 1 addition & 1 deletion alot/commands/bufferlist.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 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
from alot.commands import Command, registerCommand
from ..commands import Command, registerCommand
from . import globals

MODE = 'bufferlist'
Expand Down
52 changes: 26 additions & 26 deletions alot/commands/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@
# This file is released under the GNU GPL, version 3 or a later revision.
# For further details see the COPYING file
import argparse
import os
import re
import datetime
import email
import glob
import logging
import email
import os
import re
import tempfile

from twisted.internet.defer import inlineCallbacks
import datetime

from alot.account import SendingMailFailed, StoreMailError
from alot.errors import GPGProblem
from alot import buffers
from alot import commands
from alot import crypto
from alot.commands import Command, registerCommand
from alot.commands import globals
from alot.commands.utils import get_keys
from alot.helper import string_decode
from alot.helper import email_as_string
from alot.settings import settings
from alot.utils.booleanaction import BooleanAction
from alot.db.errors import DatabaseError
from . import Command, registerCommand
from . import globals
from .utils import get_keys
from .. import buffers
from .. import commands
from .. import crypto
from ..account import SendingMailFailed, StoreMailError
from ..db.errors import DatabaseError
from ..errors import GPGProblem
from ..helper import email_as_string
from ..helper import string_decode
from ..settings import settings
from ..utils.booleanaction import BooleanAction


MODE = 'envelope'
Expand Down Expand Up @@ -56,7 +57,7 @@ def apply(self, ui):
ui.notify('no files specified, abort')
return

logging.info("attaching: %s" % files)
logging.info("attaching: %s", files)
for path in files:
envelope.attach(path)
ui.current_buffer.rebuild()
Expand Down Expand Up @@ -193,8 +194,7 @@ def apply(self, ui):
# don't do anything if another SendCommand is in the middle of
# sending the message and we were triggered accidentally
if self.envelope.sending:
msg = 'sending this message already!'
logging.debug(msg)
logging.debug('sending this message already!')
return

clearme = ui.notify(u'constructing mail (GPG, attachments)\u2026',
Expand All @@ -204,7 +204,7 @@ def apply(self, ui):
self.mail = self.envelope.construct_mail()
self.mail['Date'] = email.Utils.formatdate(localtime=True)
self.mail = email_as_string(self.mail)
except GPGProblem, e:
except GPGProblem as e:
ui.clear_notify([clearme])
ui.notify(e.message, priority='error')
return
Expand Down Expand Up @@ -314,7 +314,7 @@ def apply(self, ui):
if '*' in blacklist:
blacklist = set(self.envelope.headers.keys())
edit_headers = edit_headers - blacklist
logging.info('editable headers: %s' % edit_headers)
logging.info('editable headers: %s', edit_headers)

def openEnvelopeFromTmpfile():
# This parses the input from the tempfile.
Expand Down Expand Up @@ -414,7 +414,7 @@ def apply(self, ui):
envelope = ui.current_buffer.envelope
if self.reset:
if self.key in envelope:
del(envelope[self.key])
del envelope[self.key]
envelope.add(self.key, self.value)
ui.current_buffer.rebuild()

Expand All @@ -432,7 +432,7 @@ def __init__(self, key, **kwargs):
Command.__init__(self, **kwargs)

def apply(self, ui):
del(ui.current_buffer.envelope[self.key])
del ui.current_buffer.envelope[self.key]
ui.current_buffer.rebuild()


Expand Down Expand Up @@ -487,7 +487,7 @@ def apply(self, ui):
keyid = str(' '.join(self.keyid))
try:
key = crypto.get_key(keyid, validate=True, sign=True)
except GPGProblem, e:
except GPGProblem as e:
envelope.sign = False
ui.notify(e.message, priority='error')
return
Expand Down Expand Up @@ -565,7 +565,7 @@ def apply(self, ui):
recipient = match.group(1)
self.encrypt_keys.append(recipient)

logging.debug("encryption keys: " + str(self.encrypt_keys))
logging.debug("encryption keys: %s", self.encrypt_keys)
keys = yield get_keys(ui, self.encrypt_keys,
signed_only=self.trusted)
if self.trusted:
Expand Down

0 comments on commit 9171f56

Please sign in to comment.