python: Make Context have a repr method.
authorTobias Mueller <muelli@cryptobitch.de>
Tue, 29 Nov 2016 22:26:20 +0000 (23:26 +0100)
committerJustus Winter <justus@g10code.com>
Thu, 1 Dec 2016 16:37:15 +0000 (17:37 +0100)
* lang/python/gpg/core.py (Context.__repr__): New function.
--

This makes Context objects look nicer in a REPL.

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
lang/python/gpg/core.py

index 748bcbb..43856ab 100644 (file)
@@ -204,6 +204,14 @@ class Context(GpgmeWrapper):
         self.pinentry_mode = pinentry_mode
         self.protocol = protocol
 
+    def __repr__(self):
+        return (
+            "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):