@classmethod
    def enable(cls, auto_colors=False, reset_atexit=False):
        if not IS_WINDOWS:
            return False  # Windows only.
        if hasattr(sys.stderr, '_original_stream') and hasattr(sys.stdout, '_original_stream'):
            return False  # Nothing to do.

        # Overwrite stream references.
        kernel32, stderr, stdout = init_kernel32()
        if not hasattr(sys.stderr, '_original_stream'):
            sys.stderr.flush()
            sys.stderr = WindowsStream(kernel32, stderr, sys.stderr)
        if not hasattr(sys.stdout, '_original_stream'):
            sys.stdout.flush()
            sys.stdout = WindowsStream(kernel32, stdout, sys.stdout)
        if not hasattr(sys.stderr, '_original_stream') and not hasattr(sys.stdout, '_original_stream'):
            return False  # Something failed.

        # Automatically select which colors to display.
        bg_color = getattr(sys.stdout, 'default_bg', getattr(sys.stderr, 'default_bg', None))
        if auto_colors and bg_color is not None:
            if bg_color in (112, 96, 240, 176, 224, 208, 160):
                ANSICodeMapping.set_light_background()
            else:
                ANSICodeMapping.set_dark_background()

        # Reset on exit if requested.
        if reset_atexit:
            atexit.register(cls.disable)

        return True
Enable color text with print() or sys.stdout.write() (stderr too).
dataset/ETHPy150Open Robpol86/colorclass/colorclass/windows.py/Windows.enable