diff options
author | Ben McGinnes <[email protected]> | 2018-06-27 14:57:37 +0000 |
---|---|---|
committer | Ben McGinnes <[email protected]> | 2018-06-28 08:51:47 +0000 |
commit | 7faef33d13fa8efce152ca7aa6e9d39030c1cf08 (patch) | |
tree | b78f720a6d04b74a2535d5249b346717e019ba51 /lang/python/src/core.py | |
parent | python bindings: export public keys (diff) | |
download | gpgme-7faef33d13fa8efce152ca7aa6e9d39030c1cf08.tar.gz gpgme-7faef33d13fa8efce152ca7aa6e9d39030c1cf08.zip |
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.
Diffstat (limited to 'lang/python/src/core.py')
-rw-r--r-- | lang/python/src/core.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lang/python/src/core.py b/lang/python/src/core.py index 86a62b51..d7db7de8 100644 --- a/lang/python/src/core.py +++ b/lang/python/src/core.py @@ -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 |