From a6819726cdaf05a479fcc5f74d2f091f85b672c7 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Wed, 29 Apr 2020 15:51:14 +0300 Subject: [PATCH] terminalwriter: remove unused function ansi_print --- src/_pytest/_io/terminalwriter.py | 56 ------------------------------- 1 file changed, 56 deletions(-) diff --git a/src/_pytest/_io/terminalwriter.py b/src/_pytest/_io/terminalwriter.py index 0e7f0ccff..6e77f2ebf 100644 --- a/src/_pytest/_io/terminalwriter.py +++ b/src/_pytest/_io/terminalwriter.py @@ -45,62 +45,6 @@ def get_line_width(text): return sum(char_width(c) for c in text) -# XXX unify with _escaped func below -def ansi_print(text, esc, file=None, newline=True, flush=False): - if file is None: - file = sys.stderr - text = text.rstrip() - if esc and not isinstance(esc, tuple): - esc = (esc,) - if esc and sys.platform != "win32" and file.isatty(): - text = ( - "".join(["\x1b[%sm" % cod for cod in esc]) + text + "\x1b[0m" - ) # ANSI color code "reset" - if newline: - text += "\n" - - if esc and win32_and_ctypes and file.isatty(): - if 1 in esc: - bold = True - esc = tuple([x for x in esc if x != 1]) - else: - bold = False - esctable = { - (): FOREGROUND_WHITE, # normal - (31,): FOREGROUND_RED, # red - (32,): FOREGROUND_GREEN, # green - (33,): FOREGROUND_GREEN | FOREGROUND_RED, # yellow - (34,): FOREGROUND_BLUE, # blue - (35,): FOREGROUND_BLUE | FOREGROUND_RED, # purple - (36,): FOREGROUND_BLUE | FOREGROUND_GREEN, # cyan - (37,): FOREGROUND_WHITE, # white - (39,): FOREGROUND_WHITE, # reset - } - attr = esctable.get(esc, FOREGROUND_WHITE) - if bold: - attr |= FOREGROUND_INTENSITY - STD_OUTPUT_HANDLE = -11 - STD_ERROR_HANDLE = -12 - if file is sys.stderr: - handle = GetStdHandle(STD_ERROR_HANDLE) - else: - handle = GetStdHandle(STD_OUTPUT_HANDLE) - oldcolors = GetConsoleInfo(handle).wAttributes - attr |= oldcolors & 0x0F0 - SetConsoleTextAttribute(handle, attr) - while len(text) > 32768: - file.write(text[:32768]) - text = text[32768:] - if text: - file.write(text) - SetConsoleTextAttribute(handle, oldcolors) - else: - file.write(text) - - if flush: - file.flush() - - def should_do_markup(file): if os.environ.get("PY_COLORS") == "1": return True