From c7590d7de0c1b9fd73718b3e698c03c652f75d3c Mon Sep 17 00:00:00 2001 From: Sébastien Larinier Date: Wed, 20 Jul 2016 11:28:24 +0200 Subject: [PATCH] mraptor compliant python3.5 --- oletools/mraptor.py | 2 +- oletools/thirdparty/tablestream/tablestream.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/oletools/mraptor.py b/oletools/mraptor.py index fabc674..cd6c28d 100755 --- a/oletools/mraptor.py +++ b/oletools/mraptor.py @@ -292,7 +292,7 @@ def main(): vba_code_all_modules = '' try: for (subfilename, stream_path, vba_filename, vba_code) in vba_parser.extract_all_macros(): - vba_code_all_modules += vba_code + '\n' + vba_code_all_modules += vba_code.decode('utf-8','replace') + '\n' except Exception as e: # log.error('Error when parsing VBA macros from file %r' % full_name) result = Result_Error diff --git a/oletools/thirdparty/tablestream/tablestream.py b/oletools/thirdparty/tablestream/tablestream.py index 9c73e5c..4a4160a 100644 --- a/oletools/thirdparty/tablestream/tablestream.py +++ b/oletools/thirdparty/tablestream/tablestream.py @@ -224,7 +224,7 @@ class TableStream(object): assert len(row) == self.num_columns columns = [] max_lines = 0 - for i in xrange(self.num_columns): + for i in range(self.num_columns): cell = row[i] # Convert to string: # TODO: handle unicode properly @@ -233,7 +233,7 @@ class TableStream(object): # encode to UTF8, avoiding errors cell = cell.decode('utf-8', errors='replace') else: - cell = unicode(cell) + cell = cell # Wrap cell text according to the column width # TODO: use a TextWrapper object for each column instead column = textwrap.wrap(cell, width=self.column_width[i]) @@ -241,16 +241,16 @@ class TableStream(object): if colors is not None and self.outfile.isatty(): color = colors[i] if color: - for j in xrange(len(column)): + for j in range(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 xrange(max_lines): + for j in range(max_lines): self.write(self.style.vertical_left) - for i in xrange(self.num_columns): + for i in range(self.num_columns): column = columns[i] if j