forked from AdaCore/gnatcoverage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_prjtrees.py
33 lines (25 loc) · 872 Bytes
/
gen_prjtrees.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import re
import subprocess
def render(tree):
subprocess.call(["dot", "-Tpng", "-o"+tree+".png", tree+".dot"])
subprocess.call(["dot", "-Tpdf", "-o"+tree+".pdf", tree+".dot"])
def gen_tree(tmpl, outfile, selected):
for l in tmpl:
m = re.search('([a-z_0-9]*) \[(.*)\];', l)
if m and m.group(1) in selected:
outfile.write(
"\t\t%s [%s,color=darkslateblue, fontcolor=white ];\n" %
(m.group(1), m.group(2)))
else:
outfile.write(l)
tmpl = open("prjtree.dot").readlines()
trees = {
'Proot-nosub': ['root'],
'Proot-ss_a-nosub': ['ss_a'],
'Proot-root-ss_a-nosub': ['root', 'ss_a'],
'Proot-ss_a': ['ss_a', 'sa1', 'sa2', 'sa3', 'common']
}
for k in trees:
gen_tree(tmpl, open(k + ".dot", "w"), trees[k])
render(k)
render('prjtree')