當前位置: 首頁>>代碼示例>>Python>>正文


Python template.output_encoding方法代碼示例

本文整理匯總了Python中mako.template.output_encoding方法的典型用法代碼示例。如果您正苦於以下問題:Python template.output_encoding方法的具體用法?Python template.output_encoding怎麽用?Python template.output_encoding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mako.template的用法示例。


在下文中一共展示了template.output_encoding方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _render_error

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import output_encoding [as 別名]
def _render_error(template, context, error):
    if template.error_handler:
        result = template.error_handler(context, error)
        if not result:
            compat.reraise(*sys.exc_info())
    else:
        error_template = exceptions.html_error_template()
        if context._outputting_as_unicode:
            context._buffer_stack[:] = [
                util.FastEncodingBuffer(as_unicode=True)
            ]
        else:
            context._buffer_stack[:] = [
                util.FastEncodingBuffer(
                    error_template.output_encoding,
                    error_template.encoding_errors,
                )
            ]

        context._set_with_template(error_template)
        error_template.render_context(context, error=error) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:23,代碼來源:runtime.py

示例2: _render

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import output_encoding [as 別名]
def _render(template, callable_, args, data, as_unicode=False):
    """create a Context and return the string
    output of the given template and template callable."""

    if as_unicode:
        buf = util.FastEncodingBuffer(as_unicode=True)
    elif template.bytestring_passthrough:
        buf = compat.StringIO()
    else:
        buf = util.FastEncodingBuffer(
            as_unicode=as_unicode,
            encoding=template.output_encoding,
            errors=template.encoding_errors)
    context = Context(buf, **data)
    context._outputting_as_unicode = as_unicode
    context._set_with_template(template)

    _render_context(template, callable_, context, *args,
                    **_kwargs_for_callable(callable_, data))
    return context._pop_buffer().getvalue() 
開發者ID:jpush,項目名稱:jbox,代碼行數:22,代碼來源:runtime.py

示例3: _render_error

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import output_encoding [as 別名]
def _render_error(template, context, error):
    if template.error_handler:
        result = template.error_handler(context, error)
        if not result:
            compat.reraise(*sys.exc_info())
    else:
        error_template = exceptions.html_error_template()
        if context._outputting_as_unicode:
            context._buffer_stack[:] = [
                util.FastEncodingBuffer(as_unicode=True)]
        else:
            context._buffer_stack[:] = [util.FastEncodingBuffer(
                error_template.output_encoding,
                error_template.encoding_errors)]

        context._set_with_template(error_template)
        error_template.render_context(context, error=error) 
開發者ID:jpush,項目名稱:jbox,代碼行數:19,代碼來源:runtime.py

示例4: _render

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import output_encoding [as 別名]
def _render(template, callable_, args, data, as_unicode=False):
    """create a Context and return the string
    output of the given template and template callable."""

    if as_unicode:
        buf = util.FastEncodingBuffer(as_unicode=True)
    elif template.bytestring_passthrough:
        buf = compat.StringIO()
    else:
        buf = util.FastEncodingBuffer(
                        as_unicode=as_unicode,
                        encoding=template.output_encoding,
                        errors=template.encoding_errors)
    context = Context(buf, **data)
    context._outputting_as_unicode = as_unicode
    context._set_with_template(template)

    _render_context(template, callable_, context, *args,
                            **_kwargs_for_callable(callable_, data))
    return context._pop_buffer().getvalue() 
開發者ID:fboender,項目名稱:ansible-cmdb,代碼行數:22,代碼來源:runtime.py

示例5: _render_error

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import output_encoding [as 別名]
def _render_error(template, context, error):
    if template.error_handler:
        result = template.error_handler(context, error)
        if not result:
            compat.reraise(*sys.exc_info())
    else:
        error_template = exceptions.html_error_template()
        if context._outputting_as_unicode:
            context._buffer_stack[:] = [
                                    util.FastEncodingBuffer(as_unicode=True)]
        else:
            context._buffer_stack[:] = [util.FastEncodingBuffer(
                                            error_template.output_encoding,
                                            error_template.encoding_errors)]

        context._set_with_template(error_template)
        error_template.render_context(context, error=error) 
開發者ID:fboender,項目名稱:ansible-cmdb,代碼行數:19,代碼來源:runtime.py

示例6: _render

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import output_encoding [as 別名]
def _render(template, callable_, args, data, as_unicode=False):
    """create a Context and return the string
    output of the given template and template callable."""

    if as_unicode:
        buf = util.FastEncodingBuffer(as_unicode=True)
    elif template.bytestring_passthrough:
        buf = compat.StringIO()
    else:
        buf = util.FastEncodingBuffer(
            as_unicode=as_unicode,
            encoding=template.output_encoding,
            errors=template.encoding_errors,
        )
    context = Context(buf, **data)
    context._outputting_as_unicode = as_unicode
    context._set_with_template(template)

    _render_context(
        template,
        callable_,
        context,
        *args,
        **_kwargs_for_callable(callable_, data)
    )
    return context._pop_buffer().getvalue() 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:28,代碼來源:runtime.py


注:本文中的mako.template.output_encoding方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。