Format the stack ready for printing. Returns a list of strings ready for printing. Each string in the resulting list corresponds to a single frame from the stack. Each string ends in a newline; the strings may contain internal newlines as well, for those items with
(self, **kwargs)
| 743 | return False |
| 744 | |
| 745 | def format(self, **kwargs): |
| 746 | """Format the stack ready for printing. |
| 747 | |
| 748 | Returns a list of strings ready for printing. Each string in the |
| 749 | resulting list corresponds to a single frame from the stack. |
| 750 | Each string ends in a newline; the strings may contain internal |
| 751 | newlines as well, for those items with source text lines. |
| 752 | |
| 753 | For long sequences of the same frame and line, the first few |
| 754 | repetitions are shown, followed by a summary line stating the exact |
| 755 | number of further repetitions. |
| 756 | """ |
| 757 | colorize = kwargs.get("colorize", False) |
| 758 | result = [] |
| 759 | last_file = None |
| 760 | last_line = None |
| 761 | last_name = None |
| 762 | count = 0 |
| 763 | for frame_summary in self: |
| 764 | formatted_frame = self.format_frame_summary(frame_summary, colorize=colorize) |
| 765 | if formatted_frame is None: |
| 766 | continue |
| 767 | if (last_file is None or last_file != frame_summary.filename or |
| 768 | last_line is None or last_line != frame_summary.lineno or |
| 769 | last_name is None or last_name != frame_summary.name): |
| 770 | if count > _RECURSIVE_CUTOFF: |
| 771 | count -= _RECURSIVE_CUTOFF |
| 772 | result.append( |
| 773 | f' [Previous line repeated {count} more ' |
| 774 | f'time{"s" if count > 1 else ""}]\n' |
| 775 | ) |
| 776 | last_file = frame_summary.filename |
| 777 | last_line = frame_summary.lineno |
| 778 | last_name = frame_summary.name |
| 779 | count = 0 |
| 780 | count += 1 |
| 781 | if count > _RECURSIVE_CUTOFF: |
| 782 | continue |
| 783 | result.append(formatted_frame) |
| 784 | |
| 785 | if count > _RECURSIVE_CUTOFF: |
| 786 | count -= _RECURSIVE_CUTOFF |
| 787 | result.append( |
| 788 | f' [Previous line repeated {count} more ' |
| 789 | f'time{"s" if count > 1 else ""}]\n' |
| 790 | ) |
| 791 | return result |
| 792 | |
| 793 | |
| 794 | def _byte_offset_to_character_offset(str, offset): |
no test coverage detected