Commit 99fcb31b75f07c6dee91a8424e22ae3cfb34c0ae
1 parent
850cbdcc
tablestream: enable colorclass on Windows, fixed issue #39
Showing
1 changed file
with
8 additions
and
6 deletions
oletools/thirdparty/tablestream/tablestream.py
| ... | ... | @@ -15,9 +15,6 @@ be processed row by row. |
| 15 | 15 | |
| 16 | 16 | Author: Philippe Lagadec - http://www.decalage.info |
| 17 | 17 | License: BSD, see source code or documentation |
| 18 | - | |
| 19 | -olemap is part of the python-oletools package: | |
| 20 | -http://www.decalage.info/python/oletools | |
| 21 | 18 | """ |
| 22 | 19 | |
| 23 | 20 | #=== LICENSE ================================================================== |
| ... | ... | @@ -50,8 +47,9 @@ http://www.decalage.info/python/oletools |
| 50 | 47 | # CHANGELOG: |
| 51 | 48 | # 2015-11-01 v0.01 PL: - first version |
| 52 | 49 | # 2016-01-01 v0.02 PL: - added styles, color support |
| 50 | +# 2016-04-19 v0.03 PL: - enable colorclass on Windows, fixed issue #39 | |
| 53 | 51 | |
| 54 | -__version__ = '0.02' | |
| 52 | +__version__ = '0.03' | |
| 55 | 53 | |
| 56 | 54 | #------------------------------------------------------------------------------ |
| 57 | 55 | # TODO: |
| ... | ... | @@ -64,10 +62,14 @@ __version__ = '0.02' |
| 64 | 62 | # === IMPORTS ================================================================= |
| 65 | 63 | |
| 66 | 64 | import textwrap |
| 67 | -import sys | |
| 65 | +import sys, os | |
| 68 | 66 | |
| 69 | 67 | from thirdparty.colorclass import colorclass |
| 70 | 68 | |
| 69 | +# On Windows, colorclass needs to be enabled: | |
| 70 | +if os.name == 'nt': | |
| 71 | + colorclass.Windows.enable(auto_colors=True) | |
| 72 | + | |
| 71 | 73 | |
| 72 | 74 | # === CLASSES ================================================================= |
| 73 | 75 | |
| ... | ... | @@ -318,7 +320,7 @@ class TableStream(object): |
| 318 | 320 | |
| 319 | 321 | |
| 320 | 322 | if __name__ == '__main__': |
| 321 | - t = TableStream([10,5,20], header_row=['i', 'i*i', '2**i'], style=TableStyleSlim) | |
| 323 | + t = TableStream([10, 5, 20], header_row=['i', 'i*i', '2**i'], style=TableStyleSlim) | |
| 322 | 324 | t.write_row(['test', 'test', 'test']) |
| 323 | 325 | cell = 'a very very long text' |
| 324 | 326 | t.write_row([cell, cell, cell], colors=['blue', None, 'red']) | ... | ... |