diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2013-09-27 22:07:24 +0200 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2013-09-27 22:07:24 +0200 |
commit | 91b24a8628b72806e1a725649a38c11e0aee6a31 (patch) | |
tree | 1a36dff322a9bd0b929a3c5d0bdd6d50740b10c3 /lib.py | |
parent | a3e9d53d41c933d92f9110663470ef553f0ed76f (diff) | |
download | cluster-overview-91b24a8628b72806e1a725649a38c11e0aee6a31.tar.gz cluster-overview-91b24a8628b72806e1a725649a38c11e0aee6a31.tar.xz cluster-overview-91b24a8628b72806e1a725649a38c11e0aee6a31.zip |
lib: reuse url attribute also for edges (not straightforward, though)
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'lib.py')
-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'): |