[Buildbot-commits] buildbot/buildbot/steps shell.py,1.15,1.16
Brian Warner
warner at users.sourceforge.net
Thu Mar 20 23:57:11 UTC 2008
Update of /cvsroot/buildbot/buildbot/buildbot/steps
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16256/buildbot/steps
Modified Files:
shell.py
Log Message:
[project @ merge in Greg Ward's WithProperties patches: changelog, fix merge conflict. Closes #115.]
Original author: warner at lothar.com
Date: 2008-03-20 23:55:52+00:00
Index: shell.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/steps/shell.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- shell.py 20 Mar 2008 23:56:58 -0000 1.15
+++ shell.py 20 Mar 2008 23:57:09 -0000 1.16
@@ -131,7 +131,6 @@
return self.description
words = self.command
- # TODO: handle WithProperties here
if isinstance(words, types.StringTypes):
words = words.split()
# render() each word to handle WithProperties objects
@@ -144,17 +143,34 @@
return ["'%s" % words[0], "%s'" % words[1]]
return ["'%s" % words[0], "%s" % words[1], "...'"]
- def _interpolateProperties(self, command):
- # interpolate any build properties into our command
- if not isinstance(command, (list, tuple)):
- return command
- command_argv = []
- for argv in command:
- if isinstance(argv, WithProperties):
- command_argv.append(argv.render(self.build))
- else:
- command_argv.append(argv)
- return command_argv
+ def _interpolateProperties(self, value):
+ """
+ Expand the L{WithProperties} objects in L{value}
+ """
+ if isinstance(value, types.StringTypes) or \
+ isinstance(value, types.BooleanType) or \
+ isinstance(value, types.IntType) or \
+ isinstance(value, types.FloatType):
+ return value
+
+ if isinstance(value, types.ListType):
+ return [self._interpolateProperties(val) for val in value]
+
+ if isinstance(value, types.TupleType):
+ return tuple([self._interpolateProperties(val) for val in value])
+
+ if isinstance(value, types.DictType):
+ new_dict = { }
+ for key, val in value.iteritems():
+ new_key = self._interpolateProperties(key)
+ new_dict[new_key] = self._interpolateProperties(val)
+ return new_dict
+
+ # To make sure we catch anything we forgot
+ assert isinstance(value, WithProperties), \
+ "%s (%s) is not a WithProperties" % (value, type(value))
+
+ return value.render(self.build)
def _interpolateWorkdir(self, workdir):
return render(workdir, self.build)
More information about the Commits
mailing list