From e168200bbb4b14242c60a940b39e83560744a9c0 Mon Sep 17 00:00:00 2001 From: Anthony King Date: Sat, 31 Oct 2015 14:30:58 -0400 Subject: py3: compare_filelist Change-Id: If44ecbf8b09732f3da72b2ade9c6172dd30e58c3 --- tools/compare_fileslist.py | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) (limited to 'tools/compare_fileslist.py') diff --git a/tools/compare_fileslist.py b/tools/compare_fileslist.py index 1f507d8..148d740 100755 --- a/tools/compare_fileslist.py +++ b/tools/compare_fileslist.py @@ -15,8 +15,17 @@ # limitations under the License. # +from __future__ import print_function + import cgi, os, string, sys + +def iteritems(obj): + if hasattr(obj, 'iteritems'): + return obj.iteritems() + return obj.items() + + def IsDifferent(row): val = None for v in row: @@ -37,23 +46,23 @@ def main(argv): lines = f.readlines() f.close() lines = map(string.split, lines) - lines = map(lambda (x,y): (y,int(x)), lines) + lines = [(x_y[1],int(x_y[0])) for x_y in lines] for fn,sz in lines: - if not data.has_key(fn): + if fn not in data: data[fn] = {} data[fn][index] = sz index = index + 1 rows = [] - for fn,sizes in data.iteritems(): + for fn,sizes in iteritems(data): row = [fn] for i in range(0,index): - if sizes.has_key(i): + if i in sizes: row.append(sizes[i]) else: row.append(None) rows.append(row) rows = sorted(rows, key=lambda x: x[0]) - print """ + print(""" - """ - print "" - print "" + """) + print("
") + print("") for input in inputs: combo = input.split(os.path.sep)[1] - print " " % cgi.escape(combo) - print "" + print(" " % cgi.escape(combo)) + print("") for row in rows: - print "" + print("") for sz in row[1:]: if not sz: - print " " + print(" ") elif IsDifferent(row[1:]): - print " " % sz + print(" " % sz) else: - print " " % sz - print " " % cgi.escape(row[0]) - print "" - print "
%s
%s
  %d%d%d%s
" - print "" + print(" %d" % sz) + print(" %s" % cgi.escape(row[0])) + print("") + print("") + print("") if __name__ == '__main__': main(sys.argv) -- cgit v1.1