def _print(string, output, frm="utf-8", strip_color=True, end=os.linesep): if is_py2exe() and not is_py2exe_console(): return can_have_color = True if strip_color and not output.isatty(): string = clicolor.strip_color(string) can_have_color = False if not PY2: # FIXME: PY3PORT can_have_color = False if isinstance(string, text_type): string = string.encode(_ENCODING, "replace") else: string = string.decode(frm).encode(_ENCODING, "replace") if isinstance(end, text_type): end = end.encode(_ENCODING, "replace") assert isinstance(string, bytes) assert isinstance(end, bytes) try: if can_have_color: clicolor.print_color(string, output) else: output.write(string) output.write(end) except IOError: pass
def _print(string, output, frm="utf-8", strip_color=True, end=os.linesep): if is_py2exe() and not is_py2exe_console(): return can_have_color = True if strip_color and not output.isatty(): string = clicolor.strip_color(string) can_have_color = False if isinstance(string, unicode): string = string.encode(_ENCODING, "replace") else: string = string.decode(frm).encode(_ENCODING, "replace") try: if can_have_color: clicolor.print_color(string, output) else: output.write(string) output.write(end) except IOError: pass
def _print(string, output, frm="utf-8", strip_color=True, end=os.linesep): if _is_py2exe() and not _is_py2exe_console(): return can_have_color = True if strip_color and not output.isatty(): string = clicolor.strip_color(string) can_have_color = False if isinstance(string, unicode): string = string.encode(ENCODING, "replace") else: string = string.decode(frm).encode(ENCODING, "replace") try: if can_have_color: clicolor.print_color(string, output) else: output.write(string) output.write(end) except IOError: pass