~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to graph.py

  • Committer: Aaron Bentley
  • Date: 2005-08-31 17:47:10 UTC
  • Revision ID: abentley@panoramicfeedback.com-20050831174710-ba3546525fd97724
support multiple image formats for graph-ancestry

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
            node_relations.append((nodes[key], nodes[value]))
84
84
    return node_relations
85
85
 
86
 
def write_ancestry_file(branch, file):
 
86
def write_ancestry_file(branch, filename):
87
87
    b = Branch(branch)
88
88
    relations = graph_ancestry(b)
89
 
    invoke_dot(dot_output(relations), file)
 
89
    ext = filename.split('.')[-1]
 
90
    if ext in ('svg', 'svgz', 'gif', 'jpg', 'ps', 'fig', 'mif', 'png'):
 
91
        invoke_dot(dot_output(relations), filename, ext)
 
92
    elif ext=='dot':
 
93
        file(filename, 'wb').write("".join(list(dot_output(relations))))
 
94
    else:
 
95
        print "Unknown file extension: %s" % ext
90
96