42def hypoToolToDot(node_labels, connections, toolname, dotdir):
43 """ Produce a dot file to visualise the nested AlgTools used
44 to configure a jet hypo AlgTool."""
45
46 text = ['digraph G{']
47 for k, l in connections.items():
48 for n in l:
49 text.append('%d -> %d;' % (k, n))
50
51 text.append('\n')
52
53 for k, label in node_labels.items():
54 description = '[shape=box, label="%s"];' % label
55 text.append('%d %s' % (k, description))
56
57 text.append('}')
58
59 text = '\n'.join(text)
60
61 if not dotdir:
62 dotdir = os.environ['HOME']
63
64 outfn = os.path.join(dotdir, toolname+'.dot')
65
66
67 with open(outfn, 'w') as fh:
68 logger.debug('writing dot file to ' + outfn)
69 fh.write(text)
70
71