summaryrefslogtreecommitdiff
path: root/alot/completion/cryptokey.py
diff options
context:
space:
mode:
Diffstat (limited to 'alot/completion/cryptokey.py')
-rw-r--r--alot/completion/cryptokey.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/alot/completion/cryptokey.py b/alot/completion/cryptokey.py
new file mode 100644
index 00000000..0631eee3
--- /dev/null
+++ b/alot/completion/cryptokey.py
@@ -0,0 +1,24 @@
+# Copyright (C) 2011-2019 Patrick Totzke <patricktotzke@gmail.com>
+# This file is released under the GNU GPL, version 3 or a later revision.
+# For further details see the COPYING file
+
+from alot import crypto
+from .stringlist import StringlistCompleter
+
+
+class CryptoKeyCompleter(StringlistCompleter):
+ """completion for gpg keys"""
+
+ def __init__(self, private=False):
+ """
+ :param private: return private keys
+ :type private: bool
+ """
+ keys = crypto.list_keys(private=private)
+ resultlist = []
+ for k in keys:
+ for s in k.subkeys:
+ resultlist.append(s.keyid)
+ for u in k.uids:
+ resultlist.append(u.email)
+ StringlistCompleter.__init__(self, resultlist, match_anywhere=True)