當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。