python bindings: export public keys

* Updated key_export and key_export_minimal to return None where a
  pattern matched no keys in a manner simnilar to the possible result
  of key_export_secret.
This commit is contained in:
Ben McGinnes 2018-06-28 00:57:37 +10:00
parent cd03423b8f
commit 483de0330d

View File

@ -578,7 +578,8 @@ class Context(GpgmeWrapper):
Returns:
-- A key block containing one or more OpenPGP keys in
either ASCII armoured or binary format as determined
by the Context().
by the Context(). If there are no matching keys it
returns None.
Raises:
GPGMEError -- as signaled by the underlying library.
@ -588,9 +589,14 @@ class Context(GpgmeWrapper):
try:
self.op_export(pattern, mode, data)
data.seek(0, os.SEEK_SET)
result = data.read()
pk_result = data.read()
except GPGMEError as e:
result = e
pk_result = e
if len(pk_result) > 0:
result = pk_result
else:
result = None
return result
@ -607,7 +613,8 @@ class Context(GpgmeWrapper):
Returns:
-- A key block containing one or more minimised OpenPGP
keys in either ASCII armoured or binary format as
determined by the Context().
determined by the Context(). If there are no matching
keys it returns None.
Raises:
GPGMEError -- as signaled by the underlying library.
@ -617,9 +624,14 @@ class Context(GpgmeWrapper):
try:
self.op_export(pattern, mode, data)
data.seek(0, os.SEEK_SET)
result = data.read()
pk_result = data.read()
except GPGMEError as e:
result = e
pk_result = e
if len(pk_result) > 0:
result = pk_result
else:
result = None
return result