Adding tests
[mozilla-central.git] / layout / generic / frame-graph.py
blobf4e58afa0069e51c9259b8bf6b0dab6007b70bdc
1 """
2 Take the *.framedata files from graph-frameclasses.js and combine them
3 into a single graphviz file.
5 stdin: a list of .framedata file names (e.g. from xargs)
6 stdout: a graphviz file
8 e.g. `find <objdir> -name "*.framedata" | python aggregate-frameclasses.py |
9 dot -Tpng -o frameclasses-graph.png -`
10 """
12 import sys
14 classdict = {}
16 for line in sys.stdin:
17 file = line.strip()
18 fd = open(file)
20 output = None
21 for line in fd:
22 if line.startswith('CLASS-DEF: '):
23 cname = line[11:-1]
24 if cname not in classdict:
25 output = classdict[cname] = []
26 else:
27 output = None
28 elif output is not None:
29 output.append(line)
31 sys.stdout.write('digraph g {\n')
33 for olist in classdict.itervalues():
34 for line in olist:
35 sys.stdout.write(line)
37 sys.stdout.write('}\n')