layout/generic/frame-graph.py

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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/.
     5 """
     6 Take the *.framedata files from graph-frameclasses.js and combine them
     7 into a single graphviz file.
     9 stdin: a list of .framedata file names (e.g. from xargs)
    10 stdout: a graphviz file
    12 e.g. `find <objdir> -name "*.framedata" | python aggregate-frameclasses.py |
    13   dot -Tpng -o frameclasses-graph.png -`
    14 """
    16 import sys
    18 classdict = {}
    20 for line in sys.stdin:
    21     file = line.strip()
    22     fd = open(file)
    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)
    35 sys.stdout.write('digraph g {\n')
    37 for olist in classdict.itervalues():
    38     for line in olist:
    39         sys.stdout.write(line)
    41 sys.stdout.write('}\n')

mercurial