michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: """ michael@0: Take the *.framedata files from graph-frameclasses.js and combine them michael@0: into a single graphviz file. michael@0: michael@0: stdin: a list of .framedata file names (e.g. from xargs) michael@0: stdout: a graphviz file michael@0: michael@0: e.g. `find -name "*.framedata" | python aggregate-frameclasses.py | michael@0: dot -Tpng -o frameclasses-graph.png -` michael@0: """ michael@0: michael@0: import sys michael@0: michael@0: classdict = {} michael@0: michael@0: for line in sys.stdin: michael@0: file = line.strip() michael@0: fd = open(file) michael@0: michael@0: output = None michael@0: for line in fd: michael@0: if line.startswith('CLASS-DEF: '): michael@0: cname = line[11:-1] michael@0: if cname not in classdict: michael@0: output = classdict[cname] = [] michael@0: else: michael@0: output = None michael@0: elif output is not None: michael@0: output.append(line) michael@0: michael@0: sys.stdout.write('digraph g {\n') michael@0: michael@0: for olist in classdict.itervalues(): michael@0: for line in olist: michael@0: sys.stdout.write(line) michael@0: michael@0: sys.stdout.write('}\n')