diff options
Diffstat (limited to 'alot/commands')
-rw-r--r-- | alot/commands/globals.py | 21 | ||||
-rw-r--r-- | alot/commands/thread.py | 46 |
2 files changed, 39 insertions, 28 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py index d335e8cf..4e272b8e 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -271,9 +271,10 @@ class ExternalCommand(Command): def thread_code(*_): try: - proc = subprocess.Popen(self.cmdlist, shell=self.shell, - stdin=subprocess.PIPE if stdin else None, - stderr=subprocess.PIPE) + proc = subprocess.Popen( + self.cmdlist, shell=self.shell, + stdin=subprocess.PIPE if stdin else None, + stderr=subprocess.PIPE) except OSError as e: return str(e) @@ -623,8 +624,8 @@ class HelpCommand(Command): globalmaps, modemaps = settings.get_keybindings(ui.mode) # build table - maxkeylength = len(max(list(modemaps.keys()) + list(globalmaps.keys()), - key=len)) + maxkeylength = len( + max(list(modemaps.keys()) + list(globalmaps.keys()), key=len)) keycolumnwidth = maxkeylength + 2 linewidgets = [] @@ -689,10 +690,12 @@ class HelpCommand(Command): class ComposeCommand(Command): """compose a new email""" - def __init__(self, envelope=None, headers=None, template=None, sender=u'', - tags=None, subject=u'', to=None, cc=None, bcc=None, attach=None, - omit_signature=False, spawn=None, rest=None, encrypt=False, - **kwargs): + def __init__( + self, + envelope=None, headers=None, template=None, sender=u'', + tags=None, subject=u'', to=None, cc=None, bcc=None, attach=None, + omit_signature=False, spawn=None, rest=None, encrypt=False, + **kwargs): """ :param envelope: use existing envelope :type envelope: :class:`~alot.db.envelope.Envelope` diff --git a/alot/commands/thread.py b/alot/commands/thread.py index a6380ac9..5d8a7939 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -72,30 +72,34 @@ def determine_sender(mail, action='reply'): # pick the most important account that has an address in candidates # and use that accounts realname and the address found here for account in my_accounts: - acc_addresses = [re.escape(str(a)) for a in account.get_addresses()] + acc_addresses = [ + re.escape(str(a)) for a in account.get_addresses()] if account.alias_regexp is not None: acc_addresses.append(account.alias_regexp) for alias in acc_addresses: regex = re.compile( u'^' + str(alias) + u'$', - flags=re.IGNORECASE if not account.address.case_sensitive else 0) + flags=( + re.IGNORECASE if not account.address.case_sensitive + else 0)) for seen_name, seen_address in candidate_addresses: - if regex.match(seen_address): - logging.debug("match!: '%s' '%s'", seen_address, alias) - if settings.get(action + '_force_realname'): - realname = account.realname - else: - realname = seen_name - if settings.get(action + '_force_address'): - address = account.address - else: - address = seen_address - - logging.debug('using realname: "%s"', realname) - logging.debug('using address: %s', address) - - from_value = formataddr((realname, str(address))) - return from_value, account + if not regex.match(seen_address): + continue + logging.debug("match!: '%s' '%s'", seen_address, alias) + if settings.get(action + '_force_realname'): + realname = account.realname + else: + realname = seen_name + if settings.get(action + '_force_address'): + address = account.address + else: + address = seen_address + + logging.debug('using realname: "%s"', realname) + logging.debug('using address: %s', address) + + from_value = formataddr((realname, str(address))) + return from_value, account # revert to default account if nothing found account = my_accounts[0] @@ -241,7 +245,11 @@ class ReplyCommand(Command): # Reply-To is standart reply target RFC 2822:, RFC 1036: 2.2.1 # X-BeenThere is needed by sourceforge ML also winehq # X-Mailing-List is also standart and is used by git-send-mail - to = mail['Reply-To'] or mail['X-BeenThere'] or mail['X-Mailing-List'] + to = ( + mail['Reply-To'] + or mail['X-BeenThere'] + or mail['X-Mailing-List'] + ) # Some mail server (gmail) will not resend you own mail, so you # have to deal with the one in sent if to is None: |