summaryrefslogtreecommitdiff
path: root/alot/crypto.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2017-07-17 10:55:19 -0700
committerDylan Baker <dylan@pnwbakers.com>2017-08-14 09:33:07 -0700
commit1c29f9b32f2abfe5b52a325b8c0a70df12f6bbf1 (patch)
tree136c4b7f0e6affde52a12cd89d62025173f363b5 /alot/crypto.py
parentc552af6a8b5e5762a657ac554cf1d8b8db78ea90 (diff)
crypto: simplify check_uid_validity
This splits the loop into a closure and a call to any, which makes it a little bit easier to read and understand.
Diffstat (limited to 'alot/crypto.py')
-rw-r--r--alot/crypto.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/alot/crypto.py b/alot/crypto.py
index 7d62bb8a..c73d792c 100644
--- a/alot/crypto.py
+++ b/alot/crypto.py
@@ -265,9 +265,10 @@ def check_uid_validity(key, email):
:returns: whether the key can be assumed to belong to the given email
:rtype: bool
"""
- for key_uid in key.uids:
- if email == key_uid.email and not key_uid.revoked and \
- not key_uid.invalid and \
- key_uid.validity >= gpg.constants.validity.FULL:
- return True
- return False
+ def check(key_uid):
+ return (email == key_uid.email and
+ not key_uid.revoked and
+ not key_uid.invalid and
+ key_uid.validity >= gpg.constants.validity.FULL)
+
+ return any(check(u) for u in key.uids)