Example #1
0
 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)
Example #2
0
 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)
Example #3
0
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()
Example #4
0
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()