Commit 3056212dd660646a6eaa8f762ef40116c115c99b

Authored by decalage2
1 parent afe9d247

olevba: do not colorize the output if it is redirected to a file (issue #402)

Showing 1 changed file with 3 additions and 1 deletions
oletools/olevba.py
... ... @@ -3561,7 +3561,9 @@ class VBA_Parser_CLI(VBA_Parser):
3561 3561 vba_code_filtered = vba_code_filtered.replace('\x08', backspace)
3562 3562 try:
3563 3563 # Colorize the interesting keywords in the output:
3564   - vba_code_filtered = colorclass.Color(self.colorize_keywords(vba_code_filtered))
  3564 + # (unless the output is redirected to a file)
  3565 + if sys.stdout.isatty():
  3566 + vba_code_filtered = colorclass.Color(self.colorize_keywords(vba_code_filtered))
3565 3567 except UnicodeError:
3566 3568 # TODO better handling of Unicode
3567 3569 log.error('Unicode conversion to be fixed before colorizing the output')
... ...