[Buildbot-devel] Using dictionaries with WithProperties objects
Nicolas Alvarez
nicolas.alvarez at gmail.com
Wed Dec 30 00:20:59 UTC 2009
Dustin J. Mitchell wrote:
> On Tue, Dec 29, 2009 at 5:38 PM, Nicolas Alvarez
> <nicolas.alvarez at gmail.com> wrote:
>> x = DeferredString(lambda s: mydict[foo])
>
> Ah, I see what you're saying. This could certainly be added to the
> Properties.render method. Maybe call it CallWithProperties?
Well, it wouldn't necessarily involve properties.
f.addStep(
ShellCommand(
command=[
"./runscript", "--random",
DS(lambda s: "%02d" % random.randint(1,100))
]
)
)
Or:
class RandomInt(DeferredString):
def __init__(self, min, max):
DeferredString.__init__(self)
self.min = min
self.max = max
def evaluate(self, step):
return random.randint(self.min, self.max)
f.addStep(ShellCommand(
command=["./runscript", "--random", RandomInt(1,100)]
))
I don't think DeferredString (or DS :P) is a good name, but
CallWithProperties isn't either, since it's not directly related to
properties at all, unless you happen to call step.getProperty from
[a subclass of] it.
--
Nicolas
(I read mailing lists through Gmane. Please don't Cc me on replies; it makes
me get one message on my newsreader and another on email.)
More information about the devel
mailing list