MCPcopy Index your code
hub / github.com/ipython/ipython / prepare_header

Method prepare_header

IPython/core/ultratb.py:715–749  ·  view source on GitHub ↗
(self, etype: str, long_version: bool = False)

Source from the content-addressed store, hash-verified

713 return result
714
715 def prepare_header(self, etype: str, long_version: bool = False) -> str:
716 width = min(75, get_terminal_size()[0])
717 if long_version:
718 # Header with the exception type, python version, and date
719 pyver = "Python " + sys.version.split()[0] + ": " + sys.executable
720 date = time.ctime(time.time())
721 theme = theme_table[self._theme_name]
722 head = theme.format(
723 [
724 (Token.Topline, theme.symbols["top_line"] * width),
725 (Token, "\n"),
726 (Token.ExcName, etype),
727 (Token, " " * (width - len(etype) - len(pyver))),
728 (Token, pyver),
729 (Token, "\n"),
730 (Token, date.rjust(width)),
731 ]
732 )
733 head += (
734 "\nA problem occurred executing Python code. Here is the sequence of function"
735 "\ncalls leading up to the error, with the most recent (innermost) call last."
736 )
737 else:
738 # Simplified header
739 head = theme_table[self._theme_name].format(
740 [
741 (Token.ExcName, etype),
742 (
743 Token,
744 "Traceback (most recent call last)".rjust(width - len(etype)),
745 ),
746 ]
747 )
748
749 return head
750
751 def format_exception(self, etype, evalue):
752 # Get (safely) a string form of the exception info

Callers 1

Calls 3

get_terminal_sizeFunction · 0.90
timeMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected