当前位置: 首页>>代码示例>>Python>>正文


Python exceptions.RichTraceback方法代码示例

本文整理汇总了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}
""") 
开发者ID:jpush,项目名称:jbox,代码行数:25,代码来源:exceptions.py

示例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}
"""
    ) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:28,代码来源:exceptions.py

示例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 
开发者ID:sqlalchemy,项目名称:mako,代码行数:41,代码来源:test_template.py

示例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 
开发者ID:jhpyle,项目名称:docassemble,代码行数:35,代码来源:test_template.py


注:本文中的mako.exceptions.RichTraceback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。