blob: 148d74057124ada66d54a1548b0c97d009a52637 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001#!/usr/bin/env python
2#
3# Copyright (C) 2009 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the 'License');
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an 'AS IS' BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
Anthony Kinge1682002015-10-31 14:30:58 -040018from __future__ import print_function
19
The Android Open Source Project88b60792009-03-03 19:28:42 -080020import cgi, os, string, sys
21
Anthony Kinge1682002015-10-31 14:30:58 -040022
23def iteritems(obj):
24 if hasattr(obj, 'iteritems'):
25 return obj.iteritems()
26 return obj.items()
27
28
The Android Open Source Project88b60792009-03-03 19:28:42 -080029def IsDifferent(row):
30 val = None
31 for v in row:
32 if v:
33 if not val:
34 val = v
35 else:
36 if val != v:
37 return True
38 return False
39
40def main(argv):
41 inputs = argv[1:]
42 data = {}
43 index = 0
44 for input in inputs:
45 f = file(input, "r")
46 lines = f.readlines()
47 f.close()
48 lines = map(string.split, lines)
Anthony Kinge1682002015-10-31 14:30:58 -040049 lines = [(x_y[1],int(x_y[0])) for x_y in lines]
The Android Open Source Project88b60792009-03-03 19:28:42 -080050 for fn,sz in lines:
Anthony Kinge1682002015-10-31 14:30:58 -040051 if fn not in data:
The Android Open Source Project88b60792009-03-03 19:28:42 -080052 data[fn] = {}
53 data[fn][index] = sz
54 index = index + 1
55 rows = []
Anthony Kinge1682002015-10-31 14:30:58 -040056 for fn,sizes in iteritems(data):
The Android Open Source Project88b60792009-03-03 19:28:42 -080057 row = [fn]
58 for i in range(0,index):
Anthony Kinge1682002015-10-31 14:30:58 -040059 if i in sizes:
The Android Open Source Project88b60792009-03-03 19:28:42 -080060 row.append(sizes[i])
61 else:
62 row.append(None)
63 rows.append(row)
64 rows = sorted(rows, key=lambda x: x[0])
Anthony Kinge1682002015-10-31 14:30:58 -040065 print("""<html>
The Android Open Source Project88b60792009-03-03 19:28:42 -080066 <head>
67 <style type="text/css">
68 .fn, .sz, .z, .d {
69 padding-left: 10px;
70 padding-right: 10px;
71 }
72 .sz, .z, .d {
73 text-align: right;
74 }
75 .fn {
76 background-color: #ffffdd;
77 }
78 .sz {
79 background-color: #ffffcc;
80 }
81 .z {
82 background-color: #ffcccc;
83 }
84 .d {
85 background-color: #99ccff;
86 }
87 </style>
88 </head>
89 <body>
Anthony Kinge1682002015-10-31 14:30:58 -040090 """)
91 print("<table>")
92 print("<tr>")
The Android Open Source Project88b60792009-03-03 19:28:42 -080093 for input in inputs:
94 combo = input.split(os.path.sep)[1]
Anthony Kinge1682002015-10-31 14:30:58 -040095 print(" <td class='fn'>%s</td>" % cgi.escape(combo))
96 print("</tr>")
The Android Open Source Project88b60792009-03-03 19:28:42 -080097
98 for row in rows:
Anthony Kinge1682002015-10-31 14:30:58 -040099 print("<tr>")
The Android Open Source Project88b60792009-03-03 19:28:42 -0800100 for sz in row[1:]:
101 if not sz:
Anthony Kinge1682002015-10-31 14:30:58 -0400102 print(" <td class='z'>&nbsp;</td>")
The Android Open Source Project88b60792009-03-03 19:28:42 -0800103 elif IsDifferent(row[1:]):
Anthony Kinge1682002015-10-31 14:30:58 -0400104 print(" <td class='d'>%d</td>" % sz)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800105 else:
Anthony Kinge1682002015-10-31 14:30:58 -0400106 print(" <td class='sz'>%d</td>" % sz)
107 print(" <td class='fn'>%s</td>" % cgi.escape(row[0]))
108 print("</tr>")
109 print("</table>")
110 print("</body></html>")
The Android Open Source Project88b60792009-03-03 19:28:42 -0800111
112if __name__ == '__main__':
113 main(sys.argv)
114
115