Home GnuPG
Diffusion GPGME db2f6c1ca3d2

python: Make Results have a nicer __repr__.
db2f6c1ca3d2Unpublished

Unpublished Commit ยท Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

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>

Details

Provenance
4tmuelleAuthored on Nov 30 2016, 8:47 AM
justusCommitted on Dec 1 2016, 5:28 PM
Parents
rMfd4d476214ae: python: Fix removing the TOFU database.
Branches
Unknown
Tags
Unknown

Event Timeline

Justus Winter <justus@g10code.com> committed rMdb2f6c1ca3d2: python: Make Results have a nicer __repr__. (authored by Tobias Mueller <muelli@cryptobitch.de>).Dec 1 2016, 5:28 PM