diff options
-rw-r--r-- | alot/account.py | 12 | ||||
-rw-r--r-- | alot/command.py | 11 | ||||
-rw-r--r-- | alot/db.py | 24 | ||||
-rw-r--r-- | alot/helper.py | 2 | ||||
-rwxr-xr-x | alot/init.py | 1 | ||||
-rw-r--r-- | alot/send.py | 3 | ||||
-rw-r--r-- | alot/settings.py | 4 | ||||
-rw-r--r-- | alot/ui.py | 11 | ||||
-rw-r--r-- | alot/widgets.py | 14 |
9 files changed, 42 insertions, 40 deletions
diff --git a/alot/account.py b/alot/account.py index 021d7c05..9dfb6a2e 100644 --- a/alot/account.py +++ b/alot/account.py @@ -38,16 +38,16 @@ class Account: self.mailbox = None if sent_mailbox: - mburl=urlparse(sent_mailbox) - if mburl.scheme=='mbox': + mburl = urlparse(sent_mailbox) + if mburl.scheme == 'mbox': self.mailbox = mailbox.mbox(mburl.path) - elif mburl.scheme=='maildir': + elif mburl.scheme == 'maildir': self.mailbox = mailbox.Maildir(mburl.path) - elif mburl.scheme=='mh': + elif mburl.scheme == 'mh': self.mailbox = mailbox.MH(mburl.path) - elif mburl.scheme=='babyl': + elif mburl.scheme == 'babyl': self.mailbox = mailbox.Babyl(mburl.path) - elif mburl.scheme=='mmdf': + elif mburl.scheme == 'mmdf': self.mailbox = mailbox.MMDF(mburl.path) if self.sender_type == 'sendmail': diff --git a/alot/command.py b/alot/command.py index 1fdeab19..ca96a770 100644 --- a/alot/command.py +++ b/alot/command.py @@ -282,12 +282,13 @@ class SendMailCommand(Command): Command.__init__(self, **kwargs) def apply(self, ui): - sname,saddr = helper.parse_addr(self.email.get('From')) + sname, saddr = helper.parse_addr(self.email.get('From')) account = get_account_by_address(saddr) if account.sender.send_mail(self.email): - if self.envelope_buffer: - ui.apply_command(BufferCloseCommand(buffer=self.envelope_buffer)) - ui.notify('mail send successful') + if self.envelope_buffer: + cmd = BufferCloseCommand(buffer=self.envelope_buffer) + ui.apply_command(cmd) + ui.notify('mail send successful') else: pass @@ -381,7 +382,7 @@ commands = { 'search': (SearchCommand, {}), 'search_prompt': (SearchPromptCommand, {}), 'refine_search_prompt': (RefineSearchPromptCommand, {}), - 'send': (SendMailCommand,{}), + 'send': (SendMailCommand, {}), 'shell': (OpenPythonShellCommand, {}), 'shutdown': (ShutdownCommand, {}), 'thread_tag_prompt': (ThreadTagPromptCommand, {}), @@ -45,33 +45,33 @@ class DBManager: try: mode = Database.MODE.READ_WRITE db = Database(path=self.path, mode=mode) - except NotmuchError,e: - if self.ui: + except NotmuchError: + if self.ui: # let the mainloop call us again after timeout timeout = config.getint('general', 'flush_retry_timeout') self.ui.update() + def f(*args): self.flush() - self.ui.mainloop.set_alarm_in(timeout,f) + self.ui.mainloop.set_alarm_in(timeout, f) return while self.writequeue: - entry = self.writequeue.popleft() - cmd,querystring,tags = entry + cmd, querystring, tags = self.writequeue.popleft() query = db.create_query(querystring) for msg in query.search_messages(): msg.freeze() - if cmd=='tag': + if cmd == 'tag': for tag in tags: msg.add_tag(tag) - if cmd=='set': + if cmd == 'set': msg.remove_all_tags() for tag in tags: msg.add_tag(tag) - elif cmd=='untag': + elif cmd == 'untag': for tag in tags: msg.remove_tag(tag) msg.thaw() self.db.upgrade() - if self.ui: + if self.ui: # trigger status update self.ui.update() def tag(self, querystring, tags, remove_rest=False): @@ -86,9 +86,9 @@ class DBManager: :type remove_rest: boolean """ if remove_rest: - self.writequeue.append(('set',querystring,tags)) + self.writequeue.append(('set', querystring, tags)) else: - self.writequeue.append(('tag',querystring,tags)) + self.writequeue.append(('tag', querystring, tags)) self.flush() def untag(self, querystring, tags): @@ -100,7 +100,7 @@ class DBManager: :param tags: a list of tags to be added :type tags: list of str """ - self.writequeue.append(('untag',querystring,tags)) + self.writequeue.append(('untag', querystring, tags)) self.flush() def count_messages(self, querystring): diff --git a/alot/helper.py b/alot/helper.py index cdc471bc..8f49cfff 100644 --- a/alot/helper.py +++ b/alot/helper.py @@ -48,6 +48,6 @@ def cmd_output(command_line): args = shlex.split(command_line) return subprocess.check_output(args) + def parse_addr(addr): return email.Utils.parseaddr(addr) - diff --git a/alot/init.py b/alot/init.py index b014ccc6..f527c430 100755 --- a/alot/init.py +++ b/alot/init.py @@ -60,7 +60,6 @@ def main(): configfilename = os.path.expanduser(args.configfile) settings.setup(configfilename) - # setup logging numeric_loglevel = getattr(logging, args.debug_level.upper(), None) logfilename = os.path.expanduser(args.logfile) diff --git a/alot/send.py b/alot/send.py index afcfcdb2..eb7638f6 100644 --- a/alot/send.py +++ b/alot/send.py @@ -44,6 +44,7 @@ class Sender: self.mailbox.flush() self.mailbox.unlock() + class SendmailSender(Sender): def __init__(self, sendmail_cmd, mailbox=None): @@ -51,7 +52,7 @@ class SendmailSender(Sender): self.mailbox = mailbox def send_mail(self, mail): - mail['Date'] = email.utils.formatdate(time.time(),True) + mail['Date'] = email.utils.formatdate(time.time(), True) args = shlex.split(self.cmd) proc = subprocess.Popen(args, stdin=subprocess.PIPE) proc.communicate(mail.as_string()) diff --git a/alot/settings.py b/alot/settings.py index 8dd435d2..51f33244 100644 --- a/alot/settings.py +++ b/alot/settings.py @@ -259,6 +259,7 @@ def get_mime_handler(mime_type, key, interactive=True): key='copiousoutput') return mc_tuple[1][key] + def get_accounts(): allowed = ['realname', 'address', @@ -289,9 +290,8 @@ def get_accounts(): def get_account_by_address(address): accounts = get_accounts() - matched = [a for a in accounts if a.address==address] + matched = [a for a in accounts if a.address == address] if len(matched) == 1: return matched.pop() else: return None - @@ -32,7 +32,7 @@ class UI: def __init__(self, db, log, accounts, initialquery, colourmode): self.dbman = db - self.dbman.ui = self #register ui with dbman + self.dbman.ui = self # register ui with dbman self.logger = log self.accounts = accounts @@ -47,7 +47,8 @@ class UI: self.mainloop.screen.set_terminal_properties(colors=colourmode) self.show_statusbar = config.getboolean('general', 'show_statusbar') - self.show_notificationbar = config.getboolean('general', 'show_notificationbar') + self.show_notificationbar = config.getboolean('general', + 'show_notificationbar') self.notificationbar = urwid.Text(' ') self.logger.debug('setup bindings') @@ -227,12 +228,12 @@ class UI: def build_statusbar(self): idx = self.buffers.index(self.current_buffer) lefttxt = '%d: [%s] %s' % (idx, self.current_buffer.typename, - self.current_buffer) + self.current_buffer) footerleft = urwid.Text(lefttxt, align='left') righttxt = 'total messages: %d' % self.dbman.count_messages('*') - pending_writes = len (self.dbman.writequeue) + pending_writes = len(self.dbman.writequeue) if pending_writes > 0: - righttxt = ('|'*pending_writes) + ' ' +righttxt + righttxt = ('|' * pending_writes) + ' ' + righttxt footerright = urwid.Text(righttxt, align='right') columns = urwid.Columns([ footerleft, diff --git a/alot/widgets.py b/alot/widgets.py index 8830e0ef..a7aa7fae 100644 --- a/alot/widgets.py +++ b/alot/widgets.py @@ -379,15 +379,15 @@ class MessageHeaderWidget(urwid.AttrMap): for key in displayed_headers: #todo: parse from,cc,bcc seperately into name-addr-widgets if key in eml: - value = reduce(lambda x,y: x+y[0], + value = reduce(lambda x, y: x + y[0], email.header.decode_header(eml[key]), '') #sanitize it a bit: - value = value.replace('\t','') - value = value.replace('\r','') - keyw = ('fixed', max_key_len+1, - urwid.Text(('message_header_key',key))) - valuew = urwid.Text(('message_header_value',value)) - line = urwid.Columns([keyw,valuew]) + value = value.replace('\t', '') + value = value.replace('\r', '') + keyw = ('fixed', max_key_len + 1, + urwid.Text(('message_header_key', key))) + valuew = urwid.Text(('message_header_value', value)) + line = urwid.Columns([keyw, valuew]) headerlines.append(line) urwid.AttrMap.__init__(self, urwid.Pile(headerlines), 'message_header') |