+ def parametrize(self, deployment, dir):
+ """
+ Takes a generic source checkout at dir and parametrizes
+ it according to the values of deployment.
+ """
+ variables = deployment.extract()
+ for file in self.parametrized_files:
+ fullpath = os.path.join(dir, file)
+ f = open(fullpath, "r")
+ contents = f.read()
+ f.close()
+ for key, value in variables.items():
+ if value is None: continue
+ contents = contents.replace(key, value)
+ tmp = tempfile.NamedTemporaryFile(delete=False)
+ tmp.write(contents)
+ tmp.close()
+ os.rename(tmp.name, fullpath)
+ def prepareConfig(self, deployment):
+ """
+ Takes a deployment and replaces any explicit instances
+ of a configuration variable with generic WIZARD_* constants.
+ There is a sane default implementation built on substitutions;
+ you can override this method to provide arbitrary extra
+ behavior.
+ """
+ for key, subst in self.substitutions.items():
+ subs = subst(deployment)
+ if not subs and key not in self.deprecated_keys:
+ logging.warning("No substitutions for %s" % key)