diff makeitso/template.py @ 65:0152741621c1

check in a failing test wrt location
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 07 Jan 2011 10:17:48 -0800
parents c20277dbf8fa
children 7821c82772f5
line wrap: on
line diff
--- a/makeitso/template.py	Thu Jan 06 18:04:58 2011 -0800
+++ b/makeitso/template.py	Fri Jan 07 10:17:48 2011 -0800
@@ -9,8 +9,8 @@
 
 class Undefined(object):
     """marker class for variables"""
-    def __int__(self):
-        return 0
+    def __nonzero__(self):
+        return False
 Undefined = Undefined() # singleton
 
 class Variable(object):
@@ -75,6 +75,7 @@
 
         # boilerplate
         assert self.templates
+        variables = variables or {}
         self.output = output
         self.interactive = interactive
         self.location = os.path.dirname(os.path.abspath(__file__))
@@ -87,14 +88,17 @@
             self.vardict[i.name] = i
 
         # ensure all of these templates exist
+        self._templates = []
         for template in self.templates:
             if template.startswith('http://') or template.startswith('https://'):
+                self._templates.append(template)
                 continue
             if os.path.isabs(template):
                 path = template
             else:
                 path = os.path.join(self.location, template)
-            assert os.path.exists(template)
+            assert os.path.exists(path), "%s does not exist" % path
+            self._templates.append(path)
 
     def get_variables(self, **variables):
         # XXX could do this in the ctor
@@ -127,6 +131,7 @@
 
     def substitute(self, **variables):
         """do the substitution"""
+        
         vars = self.get_variables(**variables)
         self.pre(**vars)
         self.check_missing(vars)
@@ -135,8 +140,7 @@
         PolyTemplate(self.templates,
                      output=self.output,
                      interactive=self.interactive,
-                     variables = vars
-                     
+                     variables=vars)
                      
         self.post(**variables)