#! /usr/bin/python
# (C) 2011 jw@suse.de, Novell Inc. 
# Distribute under any GPL.
#
import pydot
import re

# make test-at
# ./ioana.pl -l -d test/dump.ioa > dump.ioa-l

edges = []
for l in open("dump.ioa-l"):
  x = l.split()
  if (len(x) > 1):
    for i in range(1, len(x)):
      target = x[0].rstrip(':')
      source = x[i]
      if source == '(temp)': continue
      #    source =~ s{\#\d+$}{};
      source = re.sub(r"#\d+$", '', source)
      print source, target
      edges.append((source,target))

# edges=[("Hello",2), ("Hello",3), ("Hello",4), (3,4)]
g=pydot.graph_from_edges(edges, directed=True)
print "jpg"
g.write_jpeg('graph_from_edges_dot.jpg', prog='dot') 
print "svg"
g.write_svg( 'graph_from_edges_dot.svg', prog='dot') 
#print "png"
#g.write_png( 'graph_from_edges_dot.png', prog='dot') 
