def SwitchColor(fp, color): from ambuild2.ipc import winapi std = None if fp == sys.stdout: std = winapi.STD_OUTPUT_HANDLE elif fp == sys.stdin: std = winapi.STD_ERROR_HANDLE if std is None: return handle = winapi.GetStdHandle(std) winapi.SetConsoleTextAttribute(handle, color)
def SwitchColor(fp, color): from ambuild2.ipc import winapi # Ensure previously colored text is flushed before changing colors again. Otherwise text may # not be colored as expected fp.flush() std = None if fp == sys.stdout: std = winapi.STD_OUTPUT_HANDLE elif fp == sys.stdin: std = winapi.STD_ERROR_HANDLE if std is None: return handle = winapi.GetStdHandle(std) winapi.SetConsoleTextAttribute(handle, color)