[Buildbot-devel] Using dictionaries with WithProperties objects

Dustin J. Mitchell dustin at zmanda.com
Tue Dec 29 20:01:40 UTC 2009

On Tue, Dec 29, 2009 at 11:05 AM, Alexander O'Donovan-Jones
<Alexander at ccpgames.com> wrote:
> 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.

Ah, ok, this is pretty easy, because you don't need to defer any
evaluation - you can evaluate it right there.  You don't even need
WithProperties - you can just use getProperty

  key = self.getProperty("input")
  a = d[key]['var1']
  b = d[key]['var2']

Nicolas: Python syntax really prevents what you want to see, unless we
introduce PropertyKeyedDict, PropertyKeyedList, etc., which seems like
overkill.  If your properties uses are this complex, just use a custom
step - as you can see above, it's pretty easy.


Open Source Storage Engineer

More information about the devel mailing list