[git] GPGME - branch, master, updated. gpgme-1.11.1-311-g11403a4

by Ben McGinnes cvs at cvs.gnupg.org
Sun Sep 30 08:37:59 CEST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".

The branch, master has been updated
       via  11403a46358f9b6e98776974f3c70f211d9adf85 (commit)
      from  ce045a1ef9c63042fcffb5487b19646d67addba0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 11403a46358f9b6e98776974f3c70f211d9adf85
Author: Ben McGinnes <ben at adversary.org>
Date:   Sun Sep 30 16:28:54 2018 +1000

    python bindings: ctx.decrypt
    
    * lang/python/src/core.py: Fixed methods of detecting whether verify
      is a boolean variable or a list.
    * Added methods of catching the missing keys exceptions.
    * Still retained PEP8 compliance (which might have been where one or
      two problems crept in).
    * Though this is essentially the correct behaviour, it still does not
      quite fit the otiginal test; so that will also require some adjustment.
    
    Tested-by: Ben McGinnes <ben at adversary.org>
    Signed-off-by: Ben McGinnes <ben at adversary.org>

diff --git a/lang/python/src/core.py b/lang/python/src/core.py
index f440d92..17ec0ef 100644
--- a/lang/python/src/core.py
+++ b/lang/python/src/core.py
@@ -366,6 +366,8 @@ class Context(GpgmeWrapper):
         GPGMEError	-- as signaled by the underlying library
 
         """
+        sink_result = None
+        verify_sigs = None
         plaintext = sink if sink else Data()
 
         if passphrase is not None:
@@ -379,13 +381,29 @@ class Context(GpgmeWrapper):
             self.set_passphrase_cb(passphrase_cb)
 
         try:
-            if verify:
+            if verify is not None:
+                if isinstance(verify, bool) is True:
+                    if verify is False:
+                        verify = True
+                        sink_result = True
+                    else:
+                        pass
+                elif isinstance(verify, list) is True:
+                    if len(verify) > 0:
+                        verify_sigs = True
+                    else:
+                        pass
+                else:
+                    verify = True
                 self.op_decrypt_verify(ciphertext, plaintext)
             else:
                 self.op_decrypt(ciphertext, plaintext)
         except errors.GPGMEError as e:
             result = self.op_decrypt_result()
-            verify_result = self.op_verify_result() if verify else None
+            if verify is not None and sink_result is None:
+                verify_result = self.op_verify_result()
+            else:
+                verify_result = None
             # Just raise the error, but attach the results first.
             e.results = (self.__read__(sink, plaintext), result, verify_result)
             raise e
@@ -396,19 +414,25 @@ class Context(GpgmeWrapper):
                     self.set_passphrase_cb(*old_passphrase_cb[1:])
 
         result = self.op_decrypt_result()
-        verify_result = self.op_verify_result() if verify else None
+
+        if verify is not None and sink_result is None:
+            verify_result = self.op_verify_result()
+        else:
+            verify_result = None
+
         results = (self.__read__(sink, plaintext), result, verify_result)
+
         if result.unsupported_algorithm:
-            raise errors.UnsupportedAlgorithm(
-                result.unsupported_algorithm, results=results)
+            raise errors.UnsupportedAlgorithm(result.unsupported_algorithm,
+                                              results=results)
 
         if verify:
             if any(s.status != errors.NO_ERROR
                    for s in verify_result.signatures):
                 raise errors.BadSignatures(verify_result, results=results)
 
-        if not verify:  # was: if verify and verify != True:
-            missing = list()
+        if verify_sigs is not None:
+            missing = []
             for key in verify:
                 ok = False
                 for subkey in key.subkeys:
@@ -423,8 +447,28 @@ class Context(GpgmeWrapper):
                 if not ok:
                     missing.append(key)
             if missing:
-                raise errors.MissingSignatures(
-                    verify_result, missing, results=results)
+                try:
+                    raise errors.MissingSignatures(verify_result, missing,
+                                                   results=results)
+                except errors.MissingSignatures as miss_e:
+                    mse = miss_e
+                    mserr = "gpg.errors.MissingSignatures:"
+                    print(mserr, miss_e, "\n")
+                    # # The full details can then be found in mse.results,
+                    # # mse.result, mse.missing if necessary.
+                    # mse_list = []
+                    # msp = "Missing signatures from: \n".format()
+                    # print(msp)
+                    # for key in mse.missing:
+                    #     mse_list.append(key.fpr)
+                    #     msl = []
+                    #     msl.append(key.fpr)
+                    #     for user in key.uids:
+                    #         msl.append(user.name)
+                    #         msl.append(user.email)
+                    #         # msl.append(user.uid)
+                    #     print(" ".join(msl))
+                    return mse
 
         return results
 

-----------------------------------------------------------------------

Summary of changes:
 lang/python/src/core.py | 62 ++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 53 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list