Base
OutputHandler
¶
apply(self, func)
¶
applies the output options to the call funcs and returns a call wrapper which handles the output if it is activated.
Source code in camundactl/output/base.py
def apply(self, func: Callable) -> Callable:
"""
applies the output options to the call
funcs and returns a call wrapper which
handles the output if it is activated.
"""
for option in self.options.values():
func = option(func)
@functools.wraps(func)
def wrapper(*args, **kwargs):
handle_kwargs = {}
for name in self.options.keys():
handle_kwargs[name] = kwargs.pop(name)
self.ctx = self._extract_context(func, args, kwargs)
result = func(*args, **kwargs)
if self.current_output == self.name:
self.handle(result, **handle_kwargs)
return result
return wrapper