seems a bit late but I came through a google link so maybe it will help others.
To archive passing further arguments like a key as Narayanan wants, the first way is by using the .withArgs
function as it is describe in the docs
@util.renderer
def dictionary_value(props, key):
mydictionary = props.getProperty('mydictionary')
return mydictionary[key]
# pass value for key like this
f.addStep(steps.ShellCommand(command=dictionary_value.withArgs('aaa')))
withArgs
accepts a *args
or *kwargs
argument so it is pretty flexible.
The other way would be to use a Custom Renderables which implement the IRenderable
interface and overwrites its getRenderingFor
method
import time
from buildbot.interfaces import IRenderable
from zope.interface import implementer
@implementer(IRenderable)
class FromDict(object):
def __init__(self, key, default = None):
self.key = key
self.default = default
def getRenderingFor(self, props):
return props.getPropety('mydictionary', {}).value(key, default)
# When used, the renderer must be initialized and
# the parameters can be passed to its constructor
ShellCommand(command=['echo', FromDict(key='aaa', default='42')])