[Buildbot-devel] Using dictionaries with WithProperties objects

Alexander O'Donovan-Jones Alexander at ccpgames.com
Tue Dec 29 17:05:27 UTC 2009


It's a static configuration dictionary. It's used in a custom step in a factory.
It's layout is like so:
d = {
 'foo' : {'var1':1, 'var2':2},
 'bar' : {'var1':3, 'var2':4}
}

At runtime, I want to be able to specify which of these keys in the dictionary it should use, and then access the values (which in this case is a dictionary) similar to this:

A = d[WithProperties('%(input)s')]['var1']
B = d[WithProperties('%(input)s')]['var2']
With the user defining 'input'.
f.ex: if the user sets input=foo, then A==1 and B==2.

I'm doing it so that I can set specific environment variables on the slave. 


-----Original Message-----
From: djmitche at gmail.com [mailto:djmitche at gmail.com] On Behalf Of Dustin J. Mitchell
Sent: Tuesday, December 29, 2009 4:43 PM
To: Alexander O'Donovan-Jones
Cc: buildbot-devel at lists.sourceforge.net
Subject: Re: [Buildbot-devel] Using dictionaries with WithProperties objects

On Tue, Dec 29, 2009 at 7:35 AM, Alexander O'Donovan-Jones
<Alexander at ccpgames.com> wrote:
> Does anyone know of a way to use WithProperties objects in conjunction with
> a dictionary.
>
> I’ve a dictionary containing some data like so:
>
> d = {‘foo’:’bar’, ‘fooo’:’baar’}
>
>
>
> I can’t simply do a d[WithProperties(‘%(var)s’)] call, since that will raise
> a KeyError when the cfg file is compiled.
>
> Any thoughts? Even a simple monkey patch would be useful if anyone has an
> idea along that avenue.

Can you give a wider context for this?  Where is the dictionary?  When
does it need to be evaluated?  Are you doing this in a custom step?

Dustin

-- 
Open Source Storage Engineer
http://www.zmanda.com



More information about the devel mailing list