# HG changeset patch # User Jeff Hammel # Date 1295303527 28800 # Node ID c3b8ce33d3ade81e64da01e5561864d42c889e8b # Parent 51c9cb49edecfe1c13afc27f3540c957f7d94ffa make variable getting logic a little less horrible diff -r 51c9cb49edec -r c3b8ce33d3ad makeitso/makeitso.py --- a/makeitso/makeitso.py Fri Jan 14 18:36:24 2011 -0800 +++ b/makeitso/makeitso.py Mon Jan 17 14:32:07 2011 -0800 @@ -321,7 +321,7 @@ class PolyTemplate(ContentTemplate): - """template for several files/directories""" + """aggregate templates""" def __init__(self, templates, interactive=True, variables=None): self.interactive = interactive diff -r 51c9cb49edec -r c3b8ce33d3ad makeitso/template.py --- a/makeitso/template.py Fri Jan 14 18:36:24 2011 -0800 +++ b/makeitso/template.py Mon Jan 17 14:32:07 2011 -0800 @@ -137,22 +137,22 @@ return vars def missing(self, **variables): + + # boilerplate vars = self.get_variables(**variables) missing = set([]) # get known needed variables for var in self.vars: - if var.name in vars: + if var.name not in vars: if var.default is Undefined: missing.add(var.name) continue if (not self.usedefaults) and (not var.isset()): missing.add(var.name) - else: - missing.add(var.name) + # scan templates for other variables if self.look: - # scan templates for other variables template = PolyTemplate(self._templates, interactive=False, variables=vars) @@ -165,7 +165,8 @@ def substitute(self, variables, output=None): """do the substitution""" - + + # get the variables vars = self.get_variables(**variables) self.pre(vars, output) self.check_missing(vars) @@ -176,7 +177,8 @@ variables=vars) template.check_output(output) template.substitute({}, output) - + + # do whatever you need to do afterwards self.post(vars, output) def post(self, variables, output):