forked from udienz/vis-ubuntu-pkg
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvisualize.py
77 lines (54 loc) · 1.54 KB
/
visualize.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/python
import sys
import json
import config
def create_table(data):
code = {}
for arch in data:
if not arch in data:
continue
out = []
a = out.append
a('google.visualization.arrayToDataTable([')
line = ' ["Release"'
for section in config.SECTIONS:
line += ', "%s"' % section
line += '],'
a(line)
for dist in config.DISTS:
if not dist in data[arch]:
continue
line = ' ["%s"' % dist
for section in config.SECTIONS:
value = 0
if section in data[arch][dist]:
value = data[arch][dist][section]
line += ', %d' % value
line += '],'
a(line)
a(']);')
code[arch] = '\n'.join(out)
return code
def visualize_packages(data):
table = create_table(data['packages'])
print 'data["packages"] = {};';
for arch in config.ARCHS:
print 'data["packages"]["%s"] = %s' % (arch, table[arch])
def visualize_size(data):
table = create_table(data['sizes'])
print 'data["sizes"] = {};';
for arch in config.ARCHS:
print 'data["sizes"]["%s"] = %s' % (arch, table[arch])
def visualize(data):
print 'function getData() {'
print 'var data = {};'
visualize_packages(data)
visualize_size(data)
print 'return data;'
print '}'
def main():
inp = sys.argv[1]
data = json.load(open(inp))
visualize(data)
if __name__ == '__main__':
main()