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


Python compat.callable方法代码示例

本文整理汇总了Python中mako.compat.callable方法的典型用法代码示例。如果您正苦于以下问题:Python compat.callable方法的具体用法?Python compat.callable怎么用?Python compat.callable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mako.compat的用法示例。


在下文中一共展示了compat.callable方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: capture

# 需要导入模块: from mako import compat [as 别名]
# 或者: from mako.compat import callable [as 别名]
def capture(context, callable_, *args, **kwargs):
    """Execute the given template def, capturing the output into
    a buffer.

    See the example in :ref:`namespaces_python_modules`.

    """

    if not compat.callable(callable_):
        raise exceptions.RuntimeException(
            "capture() function expects a callable as "
            "its argument (i.e. capture(func, *args, **kwargs))"
        )
    context._push_buffer()
    try:
        callable_(*args, **kwargs)
    finally:
        buf = context._pop_buffer()
    return buf.getvalue() 
开发者ID:jpush,项目名称:jbox,代码行数:21,代码来源:runtime.py

示例2: _render

# 需要导入模块: from mako import compat [as 别名]
# 或者: from mako.compat import callable [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: capture

# 需要导入模块: from mako import compat [as 别名]
# 或者: from mako.compat import callable [as 别名]
def capture(context, callable_, *args, **kwargs):
    """Execute the given template def, capturing the output into
    a buffer.

    See the example in :ref:`namespaces_python_modules`.

    """

    if not compat.callable(callable_):
        raise exceptions.RuntimeException(
                        "capture() function expects a callable as "
                        "its argument (i.e. capture(func, *args, **kwargs))"
                        )
    context._push_buffer()
    try:
        callable_(*args, **kwargs)
    finally:
        buf = context._pop_buffer()
    return buf.getvalue() 
开发者ID:fboender,项目名称:ansible-cmdb,代码行数:21,代码来源:runtime.py

示例4: _render

# 需要导入模块: from mako import compat [as 别名]
# 或者: from mako.compat import callable [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: push_caller

# 需要导入模块: from mako import compat [as 别名]
# 或者: from mako.compat import callable [as 别名]
def push_caller(self, caller):
        """Push a ``caller`` callable onto the callstack for
        this :class:`.Context`."""

        self.caller_stack.append(caller) 
开发者ID:jpush,项目名称:jbox,代码行数:7,代码来源:runtime.py

示例6: pop_caller

# 需要导入模块: from mako import compat [as 别名]
# 或者: from mako.compat import callable [as 别名]
def pop_caller(self):
        """Pop a ``caller`` callable onto the callstack for this
        :class:`.Context`."""

        del self.caller_stack[-1] 
开发者ID:jpush,项目名称:jbox,代码行数:7,代码来源:runtime.py

示例7: _get_star

# 需要导入模块: from mako import compat [as 别名]
# 或者: from mako.compat import callable [as 别名]
def _get_star(self):
        if self.callables:
            for key in self.callables:
                yield (key, self.callables[key])
        for key in dir(self.module):
            if key[0] != '_':
                callable_ = getattr(self.module, key)
                if compat.callable(callable_):
                    yield key, compat.partial(callable_, self.context) 
开发者ID:jpush,项目名称:jbox,代码行数:11,代码来源:runtime.py

示例8: push_caller

# 需要导入模块: from mako import compat [as 别名]
# 或者: from mako.compat import callable [as 别名]
def push_caller(self, caller):
        """Push a ``caller`` callable onto the callstack for
        this :class:`.Context`."""


        self.caller_stack.append(caller) 
开发者ID:fboender,项目名称:ansible-cmdb,代码行数:8,代码来源:runtime.py


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