[rtags] Enhance repr of rtags 3.25
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 06 Oct 2017 10:00:36 +0200
branch3.25
changeset 12212 f2e6fb5ddf68
parent 12211 1a5911825ef5
child 12213 1d7e4f98f902
[rtags] Enhance repr of rtags * we don't care of the class, the registry id is enough (never seen a case of sub-classing) * add the module from which the rtag is coming as well as parent rtag if any.
cubicweb/rtags.py
--- a/cubicweb/rtags.py	Fri Oct 06 14:23:40 2017 +0200
+++ b/cubicweb/rtags.py	Fri Oct 06 10:00:36 2017 +0200
@@ -88,7 +88,14 @@
     def __repr__(self):
         # find a way to have more infos but keep it readable
         # (in error messages in case of an ambiguity for instance)
-        return '%s (%s): %s' % (id(self), self.__regid__, self.__class__)
+        return '<%s %s>' % (self.__regid__, self._short_repr())
+
+    def _short_repr(self):
+        # find a way to have more infos but keep it readable
+        # (in error messages in case of an ambiguity for instance)
+        return '%s@0x%x%s' % (
+            self.__module__, id(self),
+            ' derived from %s' % self._parent._short_repr() if self._parent else '')
 
     # dict compat
     def __getitem__(self, key):