RFC: arbitrary transformation for renderables
Роман Донченко
dpb at corrigendum.ru
Wed Sep 30 19:16:04 UTC 2015
Hello,
I wrote a class to simplify transforming renderables with arbitrary
functions. I think it's useful enough to include in Buildbot itself. What
do you think?
class Transform(object):
implements(IRenderable)
def __init__(self, function, *args, **kwargs):
self.function = function
self.args = args
self.kwargs = kwargs
@defer.inlineCallbacks
def getRenderingFor(self, iprops):
rfunction = yield iprops.render(self.function)
rargs = yield iprops.render(self.args)
rkwargs = yield iprops.render(self.kwargs)
defer.returnValue(rfunction(*rargs, **rkwargs))
Example uses:
Transform(lambda: datetime.date.today().isoformat()) # get build date as a
renderable
Transform(os.path.realpath, Property('builddir'))
Transform(os.path.relpath, my_file, start=Property('builddir'))
Roman.
More information about the devel
mailing list