diff --git a/slither/utils/colors.py b/slither/utils/colors.py index 1a2ff1da39..97190243b1 100644 --- a/slither/utils/colors.py +++ b/slither/utils/colors.py @@ -1,7 +1,7 @@ from functools import partial import platform import sys - +import os class Colors: # pylint: disable=too-few-public-methods COLORIZATION_ENABLED = True @@ -77,6 +77,8 @@ def set_colorization_enabled(enabled: bool) -> None: else: # This is not windows, or colorization is being disabled, so we can adjust the state immediately. Colors.COLORIZATION_ENABLED = enabled + os.environ['DISABLE_MY_PRETTY_TABLE_COLOR'] = "false" if enabled else "true" + green = partial(colorize, Colors.GREEN) diff --git a/slither/utils/myprettytable.py b/slither/utils/myprettytable.py index d67f570c0a..98beafe76a 100644 --- a/slither/utils/myprettytable.py +++ b/slither/utils/myprettytable.py @@ -1,9 +1,10 @@ from typing import List, Dict, Union from prettytable.colortable import ColorTable, Themes - +import os class MyPrettyTable: + def __init__(self, field_names: List[str], pretty_align: bool = True): # TODO: True by default? self._field_names = field_names self._rows: List = [] @@ -15,12 +16,16 @@ def __init__(self, field_names: List[str], pretty_align: bool = True): # TODO: self._options["set_alignment"] += [(field_name, "r")] else: self._options["set_alignment"] = [] + if os.getenv("DISABLE_MY_PRETTY_TABLE_COLOR")=="true": + self.theme = Themes.DEFAULT + else: + self.theme = Themes.OCEAN # keep ocean theme by default. def add_row(self, row: List[Union[str, List[str]]]) -> None: self._rows.append(row) def to_pretty_table(self) -> ColorTable: - table = ColorTable(self._field_names, theme=Themes.OCEAN) + table = ColorTable(self._field_names, theme=self.theme) for row in self._rows: table.add_row(row) if len(self._options["set_alignment"]):