[PATCH] python: Make Context have a repr method.

Tobias Mueller muelli at cryptobitch.de
Tue Nov 29 23:26:20 CET 2016


* lang/python/gpg/core.py (Context.__repr__): added
--

To look nicer in a REPL

Signed-off-by: Tobias Mueller <muelli at cryptobitch.de>
---
 lang/python/gpg/core.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lang/python/gpg/core.py b/lang/python/gpg/core.py
index 748bcbb..7b49d3b 100644
--- a/lang/python/gpg/core.py
+++ b/lang/python/gpg/core.py
@@ -204,6 +204,14 @@ class Context(GpgmeWrapper):
         self.pinentry_mode = pinentry_mode
         self.protocol = protocol
 
+    def __repr__(self):
+        return "".join((
+            "Context(armor={0.armor}, ",
+            "textmode={0.textmode}, offline={0.offline}, ",
+            "signers={0.signers}, pinentry_mode={0.pinentry_mode}, ",
+            "protocol={0.protocol}",
+            ")")).format(self)
+
     def encrypt(self, plaintext, recipients=[], sign=True, sink=None,
                 passphrase=None, always_trust=False, add_encrypt_to=False,
                 prepare=False, expect_sign=False, compress=True):
-- 
2.7.4



More information about the Gnupg-devel mailing list