def _format_traceback_lines(lines, Colors, lvals, _line_format): """ Format tracebacks lines with pointing arrow, leading numbers... Parameters ========== lines: list[Line] Colors: ColorScheme used. lvals: str Values of local variables, already colored, to inject just after the error line. _line_format: f (str) -> (str, bool) return (colorized version of str, failure to do so) """ numbers_width = INDENT_SIZE - 1 res = [] for stack_line in lines: if stack_line is stack_data.LINE_GAP: res.append('%s (...)%s\n' % (Colors.linenoEm, Colors.Normal)) continue line = stack_line.text.rstrip('\n') + '\n' new_line, err = _line_format(line, 'str') if not err: line = new_line lineno = stack_line.lineno if stack_line.is_current: # This is the line with the error pad = numbers_width - len(str(lineno)) num = '%s%s' % (debugger.make_arrow(pad), str(lineno)) line = '%s%s%s %s%s' % (Colors.linenoEm, num, Colors.line, line, Colors.Normal) else: num = '%*s' % (numbers_width, lineno) line = '%s%s%s %s' % (Colors.lineno, num, Colors.Normal, line) res.append(line) if lvals and stack_line.is_current: res.append(lvals + '\n') return res
def _format_traceback_lines(lines, Colors, has_colors, lvals): """ Format tracebacks lines with pointing arrow, leading numbers... Parameters ========== lines: list[Line] Colors: ColorScheme used. lvals: str Values of local variables, already colored, to inject just after the error line. """ numbers_width = INDENT_SIZE - 1 res = [] for stack_line in lines: if stack_line is stack_data.LINE_GAP: res.append('%s (...)%s\n' % (Colors.linenoEm, Colors.Normal)) continue line = stack_line.render(pygmented=has_colors).rstrip('\n') + '\n' lineno = stack_line.lineno if stack_line.is_current: # This is the line with the error pad = numbers_width - len(str(lineno)) num = '%s%s' % (debugger.make_arrow(pad), str(lineno)) start_color = Colors.linenoEm else: num = '%*s' % (numbers_width, lineno) start_color = Colors.lineno line = '%s%s%s %s' % (start_color, num, Colors.Normal, line) res.append(line) if lvals and stack_line.is_current: res.append(lvals + '\n') return res