本文整理汇总了Python中mako.exceptions.RichTraceback方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.RichTraceback方法的具体用法?Python exceptions.RichTraceback怎么用?Python exceptions.RichTraceback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mako.exceptions
的用法示例。
在下文中一共展示了exceptions.RichTraceback方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: text_error_template
# 需要导入模块: from mako import exceptions [as 别名]
# 或者: from mako.exceptions import RichTraceback [as 别名]
def text_error_template(lookup=None):
"""Provides a template that renders a stack trace in a similar format to
the Python interpreter, substituting source template filenames, line
numbers and code for that of the originating source template, as
applicable.
"""
import mako.template
return mako.template.Template(r"""
<%page args="error=None, traceback=None"/>
<%!
from mako.exceptions import RichTraceback
%>\
<%
tback = RichTraceback(error=error, traceback=traceback)
%>\
Traceback (most recent call last):
% for (filename, lineno, function, line) in tback.traceback:
File "${filename}", line ${lineno}, in ${function or '?'}
${line | trim}
% endfor
${tback.errorname}: ${tback.message}
""")
示例2: text_error_template
# 需要导入模块: from mako import exceptions [as 别名]
# 或者: from mako.exceptions import RichTraceback [as 别名]
def text_error_template(lookup=None):
"""Provides a template that renders a stack trace in a similar format to
the Python interpreter, substituting source template filenames, line
numbers and code for that of the originating source template, as
applicable.
"""
import mako.template
return mako.template.Template(
r"""
<%page args="error=None, traceback=None"/>
<%!
from mako.exceptions import RichTraceback
%>\
<%
tback = RichTraceback(error=error, traceback=traceback)
%>\
Traceback (most recent call last):
% for (filename, lineno, function, line) in tback.traceback:
File "${filename}", line ${lineno}, in ${function or '?'}
${line | trim}
% endfor
${tback.errorname}: ${tback.message}
"""
)
示例3: _do_test_traceback
# 需要导入模块: from mako import exceptions [as 别名]
# 或者: from mako.exceptions import RichTraceback [as 别名]
def _do_test_traceback(self, utf8, memory, syntax):
if memory:
if syntax:
source = u(
'## coding: utf-8\n<% print "m’a réveillé. '
"Elle disait: « S’il vous plaît… dessine-moi "
"un mouton! » %>"
)
else:
source = u(
'## coding: utf-8\n<% print u"m’a réveillé. '
"Elle disait: « S’il vous plaît… dessine-moi un "
'mouton! »" + str(5/0) %>'
)
if utf8:
source = source.encode("utf-8")
else:
source = source
templateargs = {"text": source}
else:
if syntax:
filename = "unicode_syntax_error.html"
else:
filename = "unicode_runtime_error.html"
source = util.read_file(self._file_path(filename), "rb")
if not utf8:
source = source.decode("utf-8")
templateargs = {"filename": self._file_path(filename)}
try:
template = Template(**templateargs)
if not syntax:
template.render_unicode()
assert False
except Exception:
tback = exceptions.RichTraceback()
if utf8:
assert tback.source == source.decode("utf-8")
else:
assert tback.source == source
示例4: _do_test_traceback
# 需要导入模块: from mako import exceptions [as 别名]
# 或者: from mako.exceptions import RichTraceback [as 别名]
def _do_test_traceback(self, utf8, memory, syntax):
if memory:
if syntax:
source = u('## coding: utf-8\n<% print "m’a réveillé. '\
'Elle disait: « S’il vous plaît… dessine-moi un mouton! » %>')
else:
source = u('## coding: utf-8\n<% print u"m’a réveillé. '\
'Elle disait: « S’il vous plaît… dessine-moi un mouton! »" + str(5/0) %>')
if utf8:
source = source.encode('utf-8')
else:
source = source
templateargs = {'text': source}
else:
if syntax:
filename = 'unicode_syntax_error.html'
else:
filename = 'unicode_runtime_error.html'
source = util.read_file(self._file_path(filename), 'rb')
if not utf8:
source = source.decode('utf-8')
templateargs = {'filename': self._file_path(filename)}
try:
template = Template(**templateargs)
if not syntax:
template.render_unicode()
assert False
except Exception:
tback = exceptions.RichTraceback()
if utf8:
assert tback.source == source.decode('utf-8')
else:
assert tback.source == source