1# This Source Code Form is subject to the terms of the Mozilla Public 2# License, v. 2.0. If a copy of the MPL was not distributed with this 3# file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5""" 6Take the *.framedata files from graph-frameclasses.js and combine them 7into a single graphviz file. 8 9stdin: a list of .framedata file names (e.g. from xargs) 10stdout: a graphviz file 11 12e.g. `find <objdir> -name "*.framedata" | python aggregate-frameclasses.py | 13 dot -Tpng -o frameclasses-graph.png -` 14""" 15 16import sys 17 18classdict = {} 19 20for line in sys.stdin: 21 file = line.strip() 22 fd = open(file) 23 24 output = None 25 for line in fd: 26 if line.startswith("CLASS-DEF: "): 27 cname = line[11:-1] 28 if cname not in classdict: 29 output = classdict[cname] = [] 30 else: 31 output = None 32 elif output is not None: 33 output.append(line) 34 35sys.stdout.write("digraph g {\n") 36 37for olist in classdict.itervalues(): 38 for line in olist: 39 sys.stdout.write(line) 40 41sys.stdout.write("}\n") 42