summaryrefslogtreecommitdiff
path: root/alot/db/utils.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2017-07-24 16:45:00 -0700
committerDylan Baker <dylan@pnwbakers.com>2017-07-24 17:05:08 -0700
commitf49cb3ce51f165529b66ba5809b1dda13919126e (patch)
tree356c9ccf1a59f241b71402e5e2174d56f52a5b22 /alot/db/utils.py
parent188c7b48467f71d4fe508569a0a16f2b88d9055d (diff)
db/utils: Improve readability
Nested ternaries are awful to read, especially in this case. Putting it into an if statement is actually more terse, and is much easier to read.
Diffstat (limited to 'alot/db/utils.py')
-rw-r--r--alot/db/utils.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/alot/db/utils.py b/alot/db/utils.py
index 29940fd9..3cad7dd2 100644
--- a/alot/db/utils.py
+++ b/alot/db/utils.py
@@ -63,18 +63,15 @@ def add_signature_headers(mail, sigs, error_msg):
sig_from = sigs[0].fpr.decode('utf-8')
uid_trusted = False
- mail.add_header(
- X_SIGNATURE_VALID_HEADER,
- 'False' if error_msg else 'True',
- )
- mail.add_header(
- X_SIGNATURE_MESSAGE_HEADER,
- u'Invalid: {0}'.format(error_msg)
- if error_msg else
- u'Valid: {0}'.format(sig_from)
- if uid_trusted else
- u'Untrusted: {0}'.format(sig_from)
- )
+ if error_msg:
+ msg = u'Invalid: {}'.format(error_msg)
+ elif uid_trusted:
+ msg = u'Valid: {}'.format(sig_from)
+ else:
+ msg = u'Untrusted: {}'.format(sig_from)
+
+ mail.add_header(X_SIGNATURE_VALID_HEADER, 'False' if error_msg else 'True')
+ mail.add_header(X_SIGNATURE_MESSAGE_HEADER, msg)
def get_params(mail, failobj=None, header='content-type', unquote=True):