def str_xml_repr(value): return tags.code( iter_join( tags.br(), value.split("\n"), ), style = 'white-space: pre;' )
def shallow_str_xml_repr(value): lines = value.split("\n") return tags.span( tags.code( lines[0], style = 'white-space: pre;' ), len(lines) > 1 and tags.b('...') or '', )
def exception_xml_repr(exception, host = None, depth = 1, memo = None): exception_type, exception_value, traceback = exc_info() stack = extract_tb(traceback)[2:] return tags.div( {'class': 'python_traceback'}, len(stack) and ( tags.p( tags.b('Traceback'), ' (most recent call last)' ), tags.ul( {'class': 'python_traceback_stack'}, ( tags.li( {'class': 'python_traceback_stack_frame'}, 'file ', tags.tt( {'class': 'python_traceback_file_name'}, file_name ), ', line ', tags.tt( {'class': 'python_traceback_line'}, line_number ), ', in ', tags.tt( {'class': 'python_traceback_function_name'}, function_name ), text is not None and ( tags.br(), tags.code( { 'class': 'python', 'style': 'white-space: pre;', }, xml_repr(text), ) ) or '' ) for file_name, line_number, function_name, text in stack ) ) ) or '', tags.p( tags.b('%s.%s' % ( exception_type.__module__, exception_type.__name__ )), ' ', str(exception_value) ), )