changeset 36:0cba953a03ca

fixed single-file test case
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 01 Jan 2011 22:13:33 -0800
parents 7e47ff4b0cd3
children 7cee2869bd7b
files examples/doctest.txt examples/example.txt makeitso/makeitso.py
diffstat 3 files changed, 8 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/examples/doctest.txt	Sat Jan 01 21:58:34 2011 -0800
+++ b/examples/doctest.txt	Sat Jan 01 22:13:33 2011 -0800
@@ -14,13 +14,13 @@
     >>> template.missing()
     set(['name'])
     >>> template.substitute(name='foo')
-    None
+    Hello foo
     
 Substitute to a buffer:
 
     >>> buffer = StringIO()
     >>> template = makeitso.PolyTemplate([example], output=buffer, interactive=False)
     >>> template.substitute(name='bar')
-    None
-    >>> buffer.getvalue()
+    >>> buffer.getvalue().strip()
+    'Hello bar'
     
--- a/examples/example.txt	Sat Jan 01 21:58:34 2011 -0800
+++ b/examples/example.txt	Sat Jan 01 22:13:33 2011 -0800
@@ -1,3 +1,2 @@
 #!/usr/bin/env makeitso
-
 Hello {{name}}
--- a/makeitso/makeitso.py	Sat Jan 01 21:58:34 2011 -0800
+++ b/makeitso/makeitso.py	Sat Jan 01 22:13:33 2011 -0800
@@ -161,7 +161,7 @@
                 vars.update(self.read_variables(missing))
             else:
                 raise MissingVariablesException(missing)
-        self._substitute(**vars)
+        return self._substitute(**vars)
 
     def _substitute(self, **variables):
         return tempita.Template.substitute(self, **variables)
@@ -270,14 +270,15 @@
 
         assert templates, "No templates given!"
 
+        self.interactive = True
         self._templates = templates[:]
         self.templates = []
         self.output = output
         for template in templates:
             if os.path.isdir(template):
-                self.templates.append(DirectoryTemplate(template, output=output, **variables))
+                self.templates.append(DirectoryTemplate(template, interactive=self.interactive, output=output, **variables))
             else:
-                self.templates.append(URITemplate(template, output=output, **variables))
+                self.templates.append(URITemplate(template, interactive=self.interactive, output=output, **variables))
 
     def missing(self, **variables):
         vars = variables.copy()
@@ -381,8 +382,7 @@
                                 variables=variables)
     else:
         template = ContentTemplate(sys.stdin.read(), variables=variables)
-        content = sys.stdin.read()
-                            
+    template.substitute()
 
     # cleanup
     cleanup()