From 19b6fd45322bb829568d2473922ce9a670acab7b Mon Sep 17 00:00:00 2001 From: decalage2 Date: Fri, 26 Aug 2016 16:42:59 +0200 Subject: [PATCH] tablestream: reverted to python 2.7 version, moved python 3 version to tablestream3.py --- oletools/thirdparty/tablestream/tablestream.py | 10 +++++----- oletools/thirdparty/tablestream/tablestream3.py | 348 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 353 insertions(+), 5 deletions(-) create mode 100644 oletools/thirdparty/tablestream/tablestream3.py diff --git a/oletools/thirdparty/tablestream/tablestream.py b/oletools/thirdparty/tablestream/tablestream.py index 2daa2f8..518d229 100644 --- a/oletools/thirdparty/tablestream/tablestream.py +++ b/oletools/thirdparty/tablestream/tablestream.py @@ -236,7 +236,7 @@ class TableStream(object): assert len(row) == self.num_columns columns = [] max_lines = 0 - for i in range(self.num_columns): + for i in xrange(self.num_columns): cell = row[i] # Convert to string: # TODO: handle unicode properly @@ -245,7 +245,7 @@ class TableStream(object): # encode to UTF8, avoiding errors cell = cell.decode('utf-8', errors='replace') else: - cell = cell + cell = unicode(cell) # Wrap cell text according to the column width # TODO: use a TextWrapper object for each column instead # split the string if it contains newline characters, otherwise @@ -257,16 +257,16 @@ class TableStream(object): if colors is not None and self.outfile.isatty(): color = colors[i] if color: - for j in range(len(column)): + for j in xrange(len(column)): # print '%r: %s' % (column[j], type(column[j])) column[j] = colorclass.Color('{auto%s}%s{/%s}' % (color, column[j], color)) columns.append(column) # determine which column has the highest number of lines max_lines = max(len(columns[i]), max_lines) # transpose: write output line by line - for j in range(max_lines): + for j in xrange(max_lines): self.write(self.style.vertical_left) - for i in range(self.num_columns): + for i in xrange(self.num_columns): column = columns[i] if j