diff options
author | Ben McGinnes <[email protected]> | 2018-06-27 14:57:37 +0000 |
---|---|---|
committer | Ben McGinnes <[email protected]> | 2018-06-27 14:57:37 +0000 |
commit | 483de0330ddcb71a94a7964e31241d7309f6c3f5 (patch) | |
tree | 3af463a5f01982ca454f0394868fdb80045b59e5 | |
parent | python bindings examples: three export scripts (diff) | |
download | gpgme-483de0330ddcb71a94a7964e31241d7309f6c3f5.tar.gz gpgme-483de0330ddcb71a94a7964e31241d7309f6c3f5.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.
-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 d1376da3..f8e0c60e 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 |