summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2013-10-23 16:51:03 +0200
committerJan Pokorný <jpokorny@redhat.com>2013-10-23 16:51:03 +0200
commit3af7028a665f295888f529fac499bdc018622bc9 (patch)
tree153d3c823b3ca0c20061f3c7be215403a313d023
parentf7337bbc39bbcbb1e41a0aba059ac70162d47fbd (diff)
downloadcluster-overview-3af7028a665f295888f529fac499bdc018622bc9.zip
cluster-overview-3af7028a665f295888f529fac499bdc018622bc9.tar.gz
cluster-overview-3af7028a665f295888f529fac499bdc018622bc9.tar.xz
Generate xdot format directly via pydot that allows customization
as used, e.g., for fonts. We are still at a single subprocess invocation after all. Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rw-r--r--lib.py51
1 files changed, 34 insertions, 17 deletions
diff --git a/lib.py b/lib.py
index 90f6f45..eb8d818 100644
--- a/lib.py
+++ b/lib.py
@@ -142,7 +142,7 @@ def gen_graph(graph, blacklist=(), **kwargs):
return graph()
-def xdot_graph(*args, **kwargs):
+def xdot_graph(graph, *args, **kwargs):
import gtk
import gtk.gdk
import pango
@@ -239,16 +239,24 @@ def xdot_graph(*args, **kwargs):
bl.append(cls)
change = True
if change and self._can_change:
- self.set_dotcode(
- gen_graph(*self._args, **self._kwargs).to_string())
+ self.set_xdotcode(
+ xdotcode = gen_graph(self._graph, **self._kwargs).create(
+ format='xdot',
+ prog=self._prog
+ )
+ )
def on_clean_all(self, widget):
self._can_change = False
for item in filter(lambda x: isinstance(x, gtk.CheckMenuItem),
widget.get_parent().get_children()):
item.set_active(False)
- self.set_dotcode(
- gen_graph(*self._args, **self._kwargs).to_string())
+ self.set_xdotcode(
+ xdotcode = gen_graph(self._graph, **self._kwargs).create(
+ format='xdot',
+ prog=self._prog
+ )
+ )
self._can_change = True
def on_set_all(self, widget):
@@ -256,25 +264,34 @@ def xdot_graph(*args, **kwargs):
for item in filter(lambda x: isinstance(x, gtk.CheckMenuItem),
widget.get_parent().get_children()):
item.set_active(True)
- self.set_dotcode(
- gen_graph(*self._args, **self._kwargs).to_string())
+ self.set_xdotcode(
+ xdotcode = gen_graph(self._graph, **self._kwargs).create(
+ format='xdot',
+ prog=self._prog
+ )
+ )
self._can_change = True
- def __init__(self, *args, **kwargs):
- self._args = args
+ def __init__(self, graph, *args, **kwargs):
+ self._graph = graph
+ self._prog = ['dot'] + list(args)
self._kwargs = kwargs
- self._can_change = True
try:
super(LibDotWindow, self).__init__(LibDotWidget())
except TypeError:
print >>stderr, "xdot too old, you won't get tooltips :-/"
super(LibDotWindow, self).__init__()
- dotcode = gen_graph(*args, **kwargs).to_string()
- title = dotcode[dotcode.find('digraph', 0, 512) + len('digraph')
- :
- dotcode.find('{', 0, 512)].strip(' \'"')
+ xdotcode = gen_graph(self._graph, **self._kwargs).create(
+ format='xdot',
+ prog=self._prog
+ )
+ title = xdotcode[xdotcode.find('digraph', 0, 512) + len('digraph')
+ :
+ xdotcode.find('{', 0, 512)].strip(' \'"')
self.base_title = title
- self.set_dotcode(dotcode)
+ self.update_title()
+ self.set_xdotcode(xdotcode)
+ self._can_change = True
mb = gtk.MenuBar()
@@ -346,7 +363,7 @@ def xdot_graph(*args, **kwargs):
self.maximize()
self.show_all()
- window = LibDotWindow(*args, **kwargs)
+ window = LibDotWindow(graph, *args, **kwargs)
window.connect('destroy', gtk.main_quit)
gtk.main()
@@ -356,7 +373,7 @@ def main(graph, argv, *args, **kws):
x, argv = (1, argv[1:]) if len(argv) <= 1 or argv[1] == '-x' else (0, argv)
output = kws.pop('output', 'sinenomine')
if x:
- xdot_graph(graph, **kws)
+ xdot_graph(graph, *args, **kws)
else:
LibMeta.promote_url = True
ext = argv[1] if len(argv) > 1 else 'pdf'