summaryrefslogtreecommitdiff
path: root/alot/commands/thread.py
diff options
context:
space:
mode:
authorLucas Hoffmann <l-m-h@web.de>2017-06-23 00:31:52 +0200
committerLucas Hoffmann <l-m-h@web.de>2017-06-23 01:26:00 +0200
commit6885f5283b2a944200bc3e4d7baf658fc57f492f (patch)
tree9ccc92b731da44e15822b093374d81507a34efb7 /alot/commands/thread.py
parent9098ea30103a4b60a563cb60b7dca4786d7530f4 (diff)
determine_sender: replace complicated break logic by return
Diffstat (limited to 'alot/commands/thread.py')
-rw-r--r--alot/commands/thread.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index c1743264..8f1ae039 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -52,9 +52,6 @@ def determine_sender(mail, action='reply'):
:type action: str
"""
assert action in ['reply', 'forward', 'bounce']
- realname = None
- address = None
- matching_account = None
# get accounts
my_accounts = settings.get_accounts()
@@ -68,8 +65,6 @@ def determine_sender(mail, action='reply'):
# account X is the one selected and not account Y.
candidate_headers = settings.get("reply_account_header_priority")
for candidate_header in candidate_headers:
- if matching_account is not None:
- break
candidate_addresses = getaddresses(mail.get_all(candidate_header, []))
logging.debug('candidate addresses: %s', candidate_addresses)
@@ -80,8 +75,6 @@ def determine_sender(mail, action='reply'):
if account.alias_regexp is not None:
acc_addresses.append(account.alias_regexp)
for alias in acc_addresses:
- if matching_account is not None:
- break
regex = re.compile('^' + alias + '$', flags=re.IGNORECASE)
for seen_name, seen_address in candidate_addresses:
if regex.match(seen_address):
@@ -94,18 +87,22 @@ def determine_sender(mail, action='reply'):
address = account.address
else:
address = seen_address
- matching_account = account
+
+ logging.debug('using realname: "%s"', realname)
+ logging.debug('using address: %s', address)
+
+ from_value = formataddr((realname, address))
+ return from_value, account
# revert to default account if nothing found
- if matching_account is None:
- matching_account = my_accounts[0]
- realname = matching_account.realname
- address = matching_account.address
+ account = my_accounts[0]
+ realname = account.realname
+ address = account.address
logging.debug('using realname: "%s"', realname)
logging.debug('using address: %s', address)
from_value = formataddr((realname, address))
- return from_value, matching_account
+ return from_value, account
@registerCommand(MODE, 'reply', arguments=[