RFC: arbitrary transformation for renderables
Pierre Tardy
tardyp at gmail.com
Thu Oct 1 21:25:36 UTC 2015
Hi Roman,
There is already a renderer function which is similar simplification of the
renderable pattern.
You can do
renderer(lambda _: datetime.date.today().isoformat()
renderer(lambda b: os.path.relpath(p.getProperty('buildir'))
The latter is a little bit more chars than your solution, but probably more
easy to follow.
http://docs.buildbot.net/latest/manual/cfg-properties.html#renderer
Regards
Pierre
Le mer. 30 sept. 2015 à 21:16, Роман Донченко <dpb at corrigendum.ru> a écrit :
> 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.
> _______________________________________________
> devel mailing list
> devel at buildbot.net
> https://lists.buildbot.net/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.buildbot.net/pipermail/devel/attachments/20151001/2196983e/attachment.html>
More information about the devel
mailing list