From e307a8174bb876ba0ac91cf1c2ced01ec4374af9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Wed, 18 Oct 2023 13:05:00 +0100 Subject: [PATCH] qapi: provide a friendly string representation of QAPI classes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- scripts/qapi/schema.py | 5 +++++ 1 file changed, 5 insertions(+) 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) -- 2.11.0