changeset 101:80a57bf2b7f4

fixed a few problems
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 11 Jan 2011 14:23:17 -0800
parents b54898f7d8a9
children ad5fd3eb6674
files makeitso/makeitso.py makeitso/template.py
diffstat 2 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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):
--- 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):