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

Method prepare_header

IPython/core/ultratb.py:1096–1116  ·  view source on GitHub ↗
(self, etype, long_version=False)

Source from the content-addressed store, hash-verified

1094 _line_format)))
1095
1096 def prepare_header(self, etype, long_version=False):
1097 colors = self.Colors # just a shorthand + quicker name lookup
1098 colorsnormal = colors.Normal # used a lot
1099 exc = '%s%s%s' % (colors.excName, etype, colorsnormal)
1100 width = min(75, get_terminal_size()[0])
1101 if long_version:
1102 # Header with the exception type, python version, and date
1103 pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable
1104 date = time.ctime(time.time())
1105
1106 head = '%s%s%s\n%s%s%s\n%s' % (colors.topline, '-' * width, colorsnormal,
1107 exc, ' ' * (width - len(str(etype)) - len(pyver)),
1108 pyver, date.rjust(width) )
1109 head += "\nA problem occurred executing Python code. Here is the sequence of function" \
1110 "\ncalls leading up to the error, with the most recent (innermost) call last."
1111 else:
1112 # Simplified header
1113 head = '%s%s' % (exc, 'Traceback (most recent call last)'. \
1114 rjust(width - len(str(etype))) )
1115
1116 return head
1117
1118 def format_exception(self, etype, evalue):
1119 colors = self.Colors # just a shorthand + quicker name lookup

Callers 1

Calls 2

get_terminal_sizeFunction · 0.90
timeMethod · 0.80

Tested by

no test coverage detected