Commit 6f3de117d7e4015e3fc8d9195b69c345c028ad50
1 parent
3b44d469
tablestream: handle newline characters properly in each cell
Showing
1 changed file
with
7 additions
and
2 deletions
oletools/thirdparty/tablestream/tablestream.py
| @@ -51,8 +51,9 @@ from __future__ import print_function | @@ -51,8 +51,9 @@ from __future__ import print_function | ||
| 51 | # 2016-04-19 v0.03 PL: - enable colorclass on Windows, fixed issue #39 | 51 | # 2016-04-19 v0.03 PL: - enable colorclass on Windows, fixed issue #39 |
| 52 | # 2016-05-25 v0.04 PL: - updated for colorclass 2.2.0 (now a package) | 52 | # 2016-05-25 v0.04 PL: - updated for colorclass 2.2.0 (now a package) |
| 53 | # 2016-07-29 v0.05 PL: - fixed oletools issue #57, bug when importing colorclass | 53 | # 2016-07-29 v0.05 PL: - fixed oletools issue #57, bug when importing colorclass |
| 54 | +# 2016-07-31 v0.06 PL: - handle newline characters properly in each cell | ||
| 54 | 55 | ||
| 55 | -__version__ = '0.05' | 56 | +__version__ = '0.06' |
| 56 | 57 | ||
| 57 | #------------------------------------------------------------------------------ | 58 | #------------------------------------------------------------------------------ |
| 58 | # TODO: | 59 | # TODO: |
| @@ -247,7 +248,11 @@ class TableStream(object): | @@ -247,7 +248,11 @@ class TableStream(object): | ||
| 247 | cell = unicode(cell) | 248 | cell = unicode(cell) |
| 248 | # Wrap cell text according to the column width | 249 | # Wrap cell text according to the column width |
| 249 | # TODO: use a TextWrapper object for each column instead | 250 | # TODO: use a TextWrapper object for each column instead |
| 250 | - column = textwrap.wrap(cell, width=self.column_width[i]) | 251 | + # split the string if it contains newline characters, otherwise |
| 252 | + # textwrap replaces them with spaces: | ||
| 253 | + column = [] | ||
| 254 | + for line in cell.splitlines(): | ||
| 255 | + column.extend(textwrap.wrap(line, width=self.column_width[i])) | ||
| 251 | # apply colors to each line of the cell if needed: | 256 | # apply colors to each line of the cell if needed: |
| 252 | if colors is not None and self.outfile.isatty(): | 257 | if colors is not None and self.outfile.isatty(): |
| 253 | color = colors[i] | 258 | color = colors[i] |