# HG changeset patch # User Jeff Hammel # Date 1294784597 28800 # Node ID 80a57bf2b7f4702393c3b2b14ec3a2b0d2f1f059 # Parent b54898f7d8a9f86fb2707ddf13f73061d4ee767e fixed a few problems diff -r b54898f7d8a9 -r 80a57bf2b7f4 makeitso/makeitso.py --- a/makeitso/makeitso.py Tue Jan 11 12:04:25 2011 -0800 +++ b/makeitso/makeitso.py Tue Jan 11 14:23:17 2011 -0800 @@ -165,8 +165,7 @@ vars.update(self.read_variables(missing)) else: raise MissingVariablesException(missing) - - + def variables(self): """return the variables needed for a template""" return self.missing() @@ -208,6 +207,8 @@ variables=variables) def substitute(self, variables, output=None): + + # interpolate content = ContentTemplate.substitute(self, **variables) # write output @@ -292,7 +293,7 @@ # interpolate directory names for d in dirnames: path = os.path.join(dirname, d) - interpolated = ContentTemplate(path).substitute(**variables) + interpolated = ContentTemplate(path).substitute(**vars) target = os.path.join(output, interpolated.split(self.name, 1)[-1].strip(os.path.sep)) if os.path.exists(target): @@ -307,7 +308,7 @@ # interpolate filenames path = os.path.join(dirname, filename) - interpolated = ContentTemplate(path).substitute(**variables) + interpolated = ContentTemplate(path).substitute(**vars) target = os.path.join(output, interpolated.split(self.name, 1)[-1].strip(os.path.sep)) # interpolate their contents @@ -315,7 +316,7 @@ # ensure its a directory assert os.path.isfile(target), "Can't substitute a file on top of a directory" template = URITemplate(path, interactive=False) - template.substitute(variables, target) + template.substitute(vars, target) class PolyTemplate(ContentTemplate): diff -r b54898f7d8a9 -r 80a57bf2b7f4 makeitso/template.py --- a/makeitso/template.py Tue Jan 11 12:04:25 2011 -0800 +++ b/makeitso/template.py Tue Jan 11 14:23:17 2011 -0800 @@ -160,14 +160,14 @@ return missing - def pre(self, variables): + def pre(self, variables, output): """do stuff before interpolation""" def substitute(self, variables, output=None): """do the substitution""" vars = self.get_variables(**variables) - self.pre(vars) + self.pre(vars, output) self.check_missing(vars) # do the substitution @@ -177,9 +177,9 @@ template.check_output(output) template.substitute({}, output) - self.post(vars) + self.post(vars, output) - def post(self, variables): + def post(self, variables, output): """do stuff after interpolation""" def read_variables(self, variables):