def render(markup, *, ensure_newline=True, file=None, renderer=Renderer): if file is None: file = sys.stdout try: fileno = file.fileno() except OSError: # This is a hack to try to get nice colorized dump output over # a remote-pdb connection. If the output is redirected to # something without fileno, use what ought to be stdout's fileno # to decide on color, etc. fileno = 1 max_width = term.size(fileno)[1] style_table = None if term.use_colors(fileno): max_colors = term.max_colors() if max_colors > 255: style_table = styles_module.Dark256 elif max_colors > 6: style_table = styles_module.Dark16 rendered = renderer.renders(markup, styles=style_table, max_width=max_width) if ensure_newline and not rendered.endswith('\n'): rendered += '\n' print(rendered, file=file, end='')
def render(markup, *, ensure_newline=True, file=None, renderer=Renderer): if file is None: file = sys.stdout fileno = file.fileno() max_width = term.size(fileno)[1] style_table = None if term.use_colors(fileno): max_colors = term.max_colors() if max_colors > 255: style_table = styles_module.Dark256 elif max_colors > 6: style_table = styles_module.Dark16 rendered = renderer.renders( markup, styles=style_table, max_width=max_width) if ensure_newline and not rendered.endswith('\n'): rendered += '\n' print(rendered, file=file, end='')