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@g10code.com>
This commit is contained in:
parent
cabd4c74e5
commit
1e6073ffa9
@ -28,7 +28,7 @@ if len(sys.argv) != 2:
|
|||||||
sys.exit("fingerprint or unique key ID for gpgme_get_key()")
|
sys.exit("fingerprint or unique key ID for gpgme_get_key()")
|
||||||
|
|
||||||
with pyme.Context(protocol=pyme.constants.PROTOCOL_CMS) as c:
|
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)
|
print("got key: ", key.subkeys[0].fpr)
|
||||||
for uid in key.uids:
|
for uid in key.uids:
|
||||||
|
@ -52,7 +52,7 @@ def verifyprintdetails(filename, detached_sig_filename=None):
|
|||||||
print(" status: %#0x" % (sign.status))
|
print(" status: %#0x" % (sign.status))
|
||||||
print(" timestamp: ", sign.timestamp)
|
print(" timestamp: ", sign.timestamp)
|
||||||
print(" fingerprint:", sign.fpr)
|
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
|
# Print "unsigned" text if inline signature
|
||||||
if data:
|
if data:
|
||||||
|
@ -670,15 +670,26 @@ class Context(GpgmeWrapper):
|
|||||||
key.__del__ = lambda self: gpgme.gpgme_key_unref(self)
|
key.__del__ = lambda self: gpgme.gpgme_key_unref(self)
|
||||||
return key
|
return key
|
||||||
|
|
||||||
def get_key(self, fpr, secret):
|
def get_key(self, fpr, secret=False):
|
||||||
"""Return the key corresponding to the fingerprint 'fpr'"""
|
"""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()
|
ptr = gpgme.new_gpgme_key_t_p()
|
||||||
errorcheck(gpgme.gpgme_get_key(self.wrapped, fpr, ptr, secret))
|
errorcheck(gpgme.gpgme_get_key(self.wrapped, fpr, ptr, secret))
|
||||||
key = gpgme.gpgme_key_t_p_value(ptr)
|
key = gpgme.gpgme_key_t_p_value(ptr)
|
||||||
gpgme.delete_gpgme_key_t_p(ptr)
|
gpgme.delete_gpgme_key_t_p(ptr)
|
||||||
if key:
|
assert key
|
||||||
key.__del__ = lambda self: gpgme.gpgme_key_unref(self)
|
key.__del__ = lambda self: gpgme.gpgme_key_unref(self)
|
||||||
return key
|
return key
|
||||||
|
|
||||||
def op_trustlist_all(self, *args, **kwargs):
|
def op_trustlist_all(self, *args, **kwargs):
|
||||||
self.op_trustlist_start(*args, **kwargs)
|
self.op_trustlist_start(*args, **kwargs)
|
||||||
|
Loading…
Reference in New Issue
Block a user