python: Make Results have a nicer __repr__.
authorTobias Mueller <muelli@cryptobitch.de>
Wed, 30 Nov 2016 07:47:29 +0000 (08:47 +0100)
committerJustus Winter <justus@g10code.com>
Thu, 1 Dec 2016 16:28:39 +0000 (17:28 +0100)
commitdb2f6c1ca3d2ef228f4ca6653d594537622c8588
tree54b7928f196c4a2dd60dfe2cd6d7ce00ea9ecf46
parentfd4d476214ae06e33f4a6dac534d3deca5cc6cd3
python: Make Results have a nicer __repr__.

* lang/python/gpg/results.py (Result.__str__): Renamed to '__repr__'
...
* lang/python/gpg/results.py (Result.__repr__): ... and added fields.
--

So that it looks a bit nicer in the Python REPL.

It looked like this before:

In [2]: gpg.core.get_engine_info()[0]
Out[2]:
<gpg.results.EngineInfo at 0x7fb23509a240>

Now the output is

In [2]: gpg.core.get_engine_info()[0]
Out[2]:
EngineInfo(file_name='/usr/bin/gpg2', home_dir=None,
protocol=0, req_version='1.4.0', version='2.1.11')

This also applies to other results, e.g. the ImportResult.

Note that the format now changed from "<Class >" to "Class()". The
Python documentation on repr states: "For many object types, including
most builtins, eval(repr(obj)) == obj."

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