changeset 113:c3b8ce33d3ad

make variable getting logic a little less horrible
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 17 Jan 2011 14:32:07 -0800
parents 51c9cb49edec
children b8d5d2041fe0
files makeitso/makeitso.py makeitso/template.py
diffstat 2 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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):