From: Daniel P. Berrangé Date: Wed, 18 Oct 2023 12:05:00 +0000 (+0100) Subject: qapi: provide a friendly string representation of QAPI classes X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=e307a8174bb876ba0ac91cf1c2ced01ec4374af9;p=qemu.git qapi: provide a friendly string representation of QAPI classes If printing a QAPI schema object for debugging we get the classname and a hex value for the instance: With this change we instead get the classname and the human friendly name of the QAPI type instance: Signed-off-by: Daniel P. Berrangé Message-ID: <20231018120500.2028642-1-berrange@redhat.com> Reviewed-by: Markus Armbruster [Conditional swapped to avoid negation] Reviewed-by: Philippe Mathieu-Daudé [Tweaked to mollify pylint] Signed-off-by: Markus Armbruster --- diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 231ebf61ba..d739e558e9 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -73,6 +73,11 @@ class QAPISchemaEntity: self.features = features or [] self._checked = False + def __repr__(self): + if self.name is None: + return "<%s at 0x%x>" % (type(self).__name__, id(self)) + return "<%s:%s at 0x%x>" % type(self).__name__, self.name, id(self) + def c_name(self): return c_name(self.name)