[Pkg-gnupg-commit] [gpgme] 40/53: python: Return public keys by default.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Mon Oct 24 19:26:52 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch experimental
in repository gpgme.
commit 1e6073ffa98db2c265adbcf0dbbe70c067a910f0
Author: Justus Winter <justus at g10code.com>
Date: Thu Oct 13 12:05:59 2016 +0200
python: Return public keys by default.
* lang/python/pyme/core.py (Core.get_key): Return public keys by
default, improve docstring.
* lang/python/examples/testCMSgetkey.py: Update example.
* lang/python/examples/verifydetails.py: Likewise.
GnuPG-bug-id: 2751
Signed-off-by: Justus Winter <justus at g10code.com>
---
lang/python/examples/testCMSgetkey.py | 2 +-
lang/python/examples/verifydetails.py | 2 +-
lang/python/pyme/core.py | 21 ++++++++++++++++-----
3 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/lang/python/examples/testCMSgetkey.py b/lang/python/examples/testCMSgetkey.py
index 4467b6c..62c35d2 100644
--- a/lang/python/examples/testCMSgetkey.py
+++ b/lang/python/examples/testCMSgetkey.py
@@ -28,7 +28,7 @@ if len(sys.argv) != 2:
sys.exit("fingerprint or unique key ID for gpgme_get_key()")
with pyme.Context(protocol=pyme.constants.PROTOCOL_CMS) as c:
- key = c.get_key(sys.argv[1], False)
+ key = c.get_key(sys.argv[1])
print("got key: ", key.subkeys[0].fpr)
for uid in key.uids:
diff --git a/lang/python/examples/verifydetails.py b/lang/python/examples/verifydetails.py
index fa34926..81f82e9 100755
--- a/lang/python/examples/verifydetails.py
+++ b/lang/python/examples/verifydetails.py
@@ -52,7 +52,7 @@ def verifyprintdetails(filename, detached_sig_filename=None):
print(" status: %#0x" % (sign.status))
print(" timestamp: ", sign.timestamp)
print(" fingerprint:", sign.fpr)
- print(" uid: ", c.get_key(sign.fpr, 0).uids[0].uid)
+ print(" uid: ", c.get_key(sign.fpr).uids[0].uid)
# Print "unsigned" text if inline signature
if data:
diff --git a/lang/python/pyme/core.py b/lang/python/pyme/core.py
index 88a086b..cd5217f 100644
--- a/lang/python/pyme/core.py
+++ b/lang/python/pyme/core.py
@@ -670,15 +670,26 @@ class Context(GpgmeWrapper):
key.__del__ = lambda self: gpgme.gpgme_key_unref(self)
return key
- def get_key(self, fpr, secret):
- """Return the key corresponding to the fingerprint 'fpr'"""
+ def get_key(self, fpr, secret=False):
+ """Get a key given a fingerprint
+
+ Keyword arguments:
+ secret -- to request a secret key
+
+ Returns:
+ -- the matching key
+
+ Raises:
+ GPGMEError -- as signaled by the underlying library
+
+ """
ptr = gpgme.new_gpgme_key_t_p()
errorcheck(gpgme.gpgme_get_key(self.wrapped, fpr, ptr, secret))
key = gpgme.gpgme_key_t_p_value(ptr)
gpgme.delete_gpgme_key_t_p(ptr)
- if key:
- key.__del__ = lambda self: gpgme.gpgme_key_unref(self)
- return key
+ assert key
+ key.__del__ = lambda self: gpgme.gpgme_key_unref(self)
+ return key
def op_trustlist_all(self, *args, **kwargs):
self.op_trustlist_start(*args, **kwargs)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gpgme.git
More information about the Pkg-gnupg-commit
mailing list