diff options
author | Johannes Kulick <kulick@hildensia.de> | 2012-12-19 11:56:31 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2013-02-19 10:10:08 +0000 |
commit | cfcd53db66a3557bdeace6a5bec435da15f14901 (patch) | |
tree | 564a8f72519a280acdfb64ef962c395195a97c3f /alot/crypto.py | |
parent | 9b8b8f5a68270912ac0dc8f16d320729b25d2da8 (diff) |
validate keys already in get_key()
this way we don't have to call validate_key wherever we use get_key. And we
would have to catch exceptions twice.
Diffstat (limited to 'alot/crypto.py')
-rw-r--r-- | alot/crypto.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/alot/crypto.py b/alot/crypto.py index 76d34e8d..3a130478 100644 --- a/alot/crypto.py +++ b/alot/crypto.py @@ -108,7 +108,7 @@ def RFC3156_canonicalize(text): return text -def get_key(keyid): +def get_key(keyid, validate=False, encrypt=False, sign=False): """ Gets a key from the keyring by filtering for the specified keyid, but only if the given keyid is specific enough (if it matches multiple @@ -120,6 +120,8 @@ def get_key(keyid): ctx = gpgme.Context() try: key = ctx.get_key(keyid) + if validate: + validate_key(key, encrypt=encrypt, sign=sign) except gpgme.GpgmeError as e: if e.code == gpgme.ERR_AMBIGUOUS_NAME: raise GPGProblem(("More than one key found matching this filter." + @@ -134,7 +136,7 @@ def get_key(keyid): return key -def list_keys(private=False): +def list_keys(hint=None, private=False): """ Returns a list of all keys containing keyid. @@ -143,7 +145,7 @@ def list_keys(private=False): :rtype: list """ ctx = gpgme.Context() - return ctx.keylist(None, private) + return ctx.keylist(hint, private) def detached_signature_for(plaintext_str, key=None): |