diff options
-rw-r--r-- | lib.py | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -72,7 +72,11 @@ class LibMeta(type): if hasattr(self, 'web'): kwargs['URL'] = getattr(self, 'web', None) else: - kwargs['URL'] = "class://" + self.__class__.__name__ + url = "class://" + self.__class__.__name__ + for l in ('common_src_of', 'common_dst_of'): + url += ';' + url += getattr(self, l).__name__ if hasattr(self, l) else '' + kwargs['URL'] = url old_init(self, *args, **kwargs) super(cls, self).__init__(*args, **kwargs) @@ -157,10 +161,22 @@ def xdot_graph(*args, **kwargs): lambda self, *args: self.set_tooltip_markup(None)) def on_click(self, element, event): - if element is None or not element.url: + """Overload url attribute as it is the only passed internally""" + if element is None: return False + elif not hasattr(element, 'url'): + assert isinstance(element, xdot.Edge) + for access, i in ((element.src, 1), (element.dst, 2)): + which = access.url.split('class://', 1)[1].split(';')[i] + if which in REGISTRY: + # XXX: check matching label to be perfectly sure + cls = REGISTRY[which] + break + else: + return False + else: + cls = REGISTRY[element.url.split('class://', 1)[1].split(';')[0]] # create the resulting markup - cls = REGISTRY[element.url.split('class://', 1)[1]] markup = "" # XXX: sort the keys in dicts? if hasattr(cls, 'summary'): |