MCPcopy Create free account
hub / github.com/ipython/ipython / _format_list

Method _format_list

IPython/core/ultratb.py:706–741  ·  view source on GitHub ↗

Format a list of traceback entry tuples for printing. Given a list of tuples as returned by extract_tb() or extract_stack(), return a list of strings ready for printing. Each string in the resulting list corresponds to the item with the same index in the argument lis

(self, extracted_list)

Source from the content-addressed store, hash-verified

704 return out_list
705
706 def _format_list(self, extracted_list):
707 """Format a list of traceback entry tuples for printing.
708
709 Given a list of tuples as returned by extract_tb() or
710 extract_stack(), return a list of strings ready for printing.
711 Each string in the resulting list corresponds to the item with the
712 same index in the argument list. Each string ends in a newline;
713 the strings may contain internal newlines as well, for those items
714 whose source text line is not None.
715
716 Lifted almost verbatim from traceback.py
717 """
718
719 Colors = self.Colors
720 list = []
721 for filename, lineno, name, line in extracted_list[:-1]:
722 item = ' File %s"%s"%s, line %s%d%s, in %s%s%s\n' % \
723 (Colors.filename, filename, Colors.Normal,
724 Colors.lineno, lineno, Colors.Normal,
725 Colors.name, name, Colors.Normal)
726 if line:
727 item += ' %s\n' % line.strip()
728 list.append(item)
729 # Emphasize the last entry
730 filename, lineno, name, line = extracted_list[-1]
731 item = '%s File %s"%s"%s, line %s%d%s, in %s%s%s%s\n' % \
732 (Colors.normalEm,
733 Colors.filenameEm, filename, Colors.normalEm,
734 Colors.linenoEm, lineno, Colors.normalEm,
735 Colors.nameEm, name, Colors.normalEm,
736 Colors.Normal)
737 if line:
738 item += '%s %s%s\n' % (Colors.line, line.strip(),
739 Colors.Normal)
740 list.append(item)
741 return list
742
743 def _format_exception_only(self, etype, value):
744 """Format the exception part of a traceback.

Callers 1

structured_tracebackMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected