summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2013-09-27 22:07:24 +0200
committerJan Pokorný <jpokorny@redhat.com>2013-09-27 22:07:24 +0200
commit91b24a8628b72806e1a725649a38c11e0aee6a31 (patch)
tree1a36dff322a9bd0b929a3c5d0bdd6d50740b10c3
parenta3e9d53d41c933d92f9110663470ef553f0ed76f (diff)
downloadcluster-overview-91b24a8628b72806e1a725649a38c11e0aee6a31.zip
cluster-overview-91b24a8628b72806e1a725649a38c11e0aee6a31.tar.gz
cluster-overview-91b24a8628b72806e1a725649a38c11e0aee6a31.tar.xz
lib: reuse url attribute also for edges (not straightforward, though)
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rw-r--r--lib.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib.py b/lib.py
index 26f0b9c..04ed31f 100644
--- a/lib.py
+++ b/lib.py
@@ -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'):