The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | #!/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 King | e168200 | 2015-10-31 14:30:58 -0400 | [diff] [blame] | 18 | from __future__ import print_function |
| 19 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 20 | import cgi, os, string, sys |
| 21 | |
Anthony King | e168200 | 2015-10-31 14:30:58 -0400 | [diff] [blame] | 22 | |
| 23 | def iteritems(obj): |
| 24 | if hasattr(obj, 'iteritems'): |
| 25 | return obj.iteritems() |
| 26 | return obj.items() |
| 27 | |
| 28 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 29 | def 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 | |
| 40 | def 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 King | e168200 | 2015-10-31 14:30:58 -0400 | [diff] [blame] | 49 | lines = [(x_y[1],int(x_y[0])) for x_y in lines] |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 50 | for fn,sz in lines: |
Anthony King | e168200 | 2015-10-31 14:30:58 -0400 | [diff] [blame] | 51 | if fn not in data: |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 52 | data[fn] = {} |
| 53 | data[fn][index] = sz |
| 54 | index = index + 1 |
| 55 | rows = [] |
Anthony King | e168200 | 2015-10-31 14:30:58 -0400 | [diff] [blame] | 56 | for fn,sizes in iteritems(data): |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 57 | row = [fn] |
| 58 | for i in range(0,index): |
Anthony King | e168200 | 2015-10-31 14:30:58 -0400 | [diff] [blame] | 59 | if i in sizes: |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 60 | row.append(sizes[i]) |
| 61 | else: |
| 62 | row.append(None) |
| 63 | rows.append(row) |
| 64 | rows = sorted(rows, key=lambda x: x[0]) |
Anthony King | e168200 | 2015-10-31 14:30:58 -0400 | [diff] [blame] | 65 | print("""<html> |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 66 | <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 King | e168200 | 2015-10-31 14:30:58 -0400 | [diff] [blame] | 90 | """) |
| 91 | print("<table>") |
| 92 | print("<tr>") |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 93 | for input in inputs: |
| 94 | combo = input.split(os.path.sep)[1] |
Anthony King | e168200 | 2015-10-31 14:30:58 -0400 | [diff] [blame] | 95 | print(" <td class='fn'>%s</td>" % cgi.escape(combo)) |
| 96 | print("</tr>") |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 97 | |
| 98 | for row in rows: |
Anthony King | e168200 | 2015-10-31 14:30:58 -0400 | [diff] [blame] | 99 | print("<tr>") |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 100 | for sz in row[1:]: |
| 101 | if not sz: |
Anthony King | e168200 | 2015-10-31 14:30:58 -0400 | [diff] [blame] | 102 | print(" <td class='z'> </td>") |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 103 | elif IsDifferent(row[1:]): |
Anthony King | e168200 | 2015-10-31 14:30:58 -0400 | [diff] [blame] | 104 | print(" <td class='d'>%d</td>" % sz) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 105 | else: |
Anthony King | e168200 | 2015-10-31 14:30:58 -0400 | [diff] [blame] | 106 | 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 Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 111 | |
| 112 | if __name__ == '__main__': |
| 113 | main(sys.argv) |
| 114 | |
| 115 | |