def main(argv=None): if argv is None: argv = sys.argv try: try: opts, args = getopt.getopt(argv[1:], "ho:v", ["help", "output="]) except getopt.error, msg: raise Usage(msg) # option processing for option, value in opts: if option == "-v": verbose = True if option in ("-h", "--help"): raise Usage(help_message) if option in ("-o", "--output"): output = value iddfile = "../iddfiles/Energy+V6_0.idd" fname = args[0] iddfile = "../iddfiles/Energy+V6_0.idd" print "readingfile" data, commdct = readidf.readdatacommdct(fname, iddfile=iddfile) print "constructing the loops" edges = makeairplantloop(data, commdct) edges = diagram.cleanedges(edges) print "making the diagram" g = diagram.makediagram(edges) dotname = '%s_c.dot' % (os.path.splitext(fname)[0]) pngname = '%s_c.png' % (os.path.splitext(fname)[0]) g.write(dotname) g.write_png(pngname)
def test_cleanedges(): """py.test for cleanedges""" thedata = ( ( (('a:b', 'b'), ('a:b', 'c')), u'*', [[u'a*b', u'b'], [u'a*b', u'c']]), # edges, replacechar, newedges ( (('a:b', ('b', "epnode")), ('a:b', 'c')), u'*', [[u'a*b', ( u'b', u'epnode')], [u'a*b', u'c']]), # edges, replacechar, newedges ) for edges, replacechar, newedges in thedata: result = diagram.cleanedges(edges, replacechar='*') print result print newedges assert result == newedges
"""testing unicode make diagrams. Can be deleted once done""" import diagram edges = (('a', 'b'), ('a', 'c')) edges = ((('a', "epnode"), 'b:d'), (('a', "epnode"), 'c')) edges = diagram.cleanedges(edges) g = diagram.makediagram(edges) g.write_png('a.png')