Mercurial > hg > MakeItSo
comparison makeitso/makeitso.py @ 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 |
comparison
equal
deleted
inserted
replaced
35:7e47ff4b0cd3 | 36:0cba953a03ca |
---|---|
159 if missing: | 159 if missing: |
160 if self.interactive: | 160 if self.interactive: |
161 vars.update(self.read_variables(missing)) | 161 vars.update(self.read_variables(missing)) |
162 else: | 162 else: |
163 raise MissingVariablesException(missing) | 163 raise MissingVariablesException(missing) |
164 self._substitute(**vars) | 164 return self._substitute(**vars) |
165 | 165 |
166 def _substitute(self, **variables): | 166 def _substitute(self, **variables): |
167 return tempita.Template.substitute(self, **variables) | 167 return tempita.Template.substitute(self, **variables) |
168 | 168 |
169 def read_variables(self, variables): | 169 def read_variables(self, variables): |
268 | 268 |
269 def __init__(self, templates, output=None, interactive=True, **variables): | 269 def __init__(self, templates, output=None, interactive=True, **variables): |
270 | 270 |
271 assert templates, "No templates given!" | 271 assert templates, "No templates given!" |
272 | 272 |
273 self.interactive = True | |
273 self._templates = templates[:] | 274 self._templates = templates[:] |
274 self.templates = [] | 275 self.templates = [] |
275 self.output = output | 276 self.output = output |
276 for template in templates: | 277 for template in templates: |
277 if os.path.isdir(template): | 278 if os.path.isdir(template): |
278 self.templates.append(DirectoryTemplate(template, output=output, **variables)) | 279 self.templates.append(DirectoryTemplate(template, interactive=self.interactive, output=output, **variables)) |
279 else: | 280 else: |
280 self.templates.append(URITemplate(template, output=output, **variables)) | 281 self.templates.append(URITemplate(template, interactive=self.interactive, output=output, **variables)) |
281 | 282 |
282 def missing(self, **variables): | 283 def missing(self, **variables): |
283 vars = variables.copy() | 284 vars = variables.copy() |
284 missing = set([]) | 285 missing = set([]) |
285 for template in self.templates: | 286 for template in self.templates: |
379 template = PolyTemplate(templates=args, | 380 template = PolyTemplate(templates=args, |
380 output=options.output, | 381 output=options.output, |
381 variables=variables) | 382 variables=variables) |
382 else: | 383 else: |
383 template = ContentTemplate(sys.stdin.read(), variables=variables) | 384 template = ContentTemplate(sys.stdin.read(), variables=variables) |
384 content = sys.stdin.read() | 385 template.substitute() |
385 | |
386 | 386 |
387 # cleanup | 387 # cleanup |
388 cleanup() | 388 cleanup() |
389 | 389 |
390 if __name__ == '__main__': | 390 if __name__ == '__main__': |