comparison makeitso/makeitso.py @ 54:d3e1e5745f24

pass the variables, fixes tests
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 06 Jan 2011 13:14:12 -0800
parents 599c365d9105
children b087a14a664b
comparison
equal deleted inserted replaced
53:599c365d9105 54:d3e1e5745f24
170 """return the variables needed for a template""" 170 """return the variables needed for a template"""
171 return self.missing() 171 return self.missing()
172 172
173 def substitute(self, **variables): 173 def substitute(self, **variables):
174 """interactive (for now) substitution""" 174 """interactive (for now) substitution"""
175 vars = self.get_variables() 175 vars = self.get_variables(**variables)
176 self.check_missing(vars) 176 self.check_missing(vars)
177 return self._substitute(**vars) 177 return self._substitute(**vars)
178 178
179 def _substitute(self, **variables): 179 def _substitute(self, **variables):
180 return tempita.Template.substitute(self, **variables) 180 return tempita.Template.substitute(self, **variables)
248 variables.update(dict([(i, '') for i in missed])) 248 variables.update(dict([(i, '') for i in missed]))
249 249
250 # find variables from files 250 # find variables from files
251 for f in filenames: 251 for f in filenames:
252 path = os.path.join(dirpath, f) 252 path = os.path.join(dirpath, f)
253 template = URITemplate(path, self.interactive=self.interactive) 253 template = URITemplate(path, interactive=self.interactive)
254 missed = template.missing(**variables) 254 missed = template.missing(**variables)
255 missing.update(missed) 255 missing.update(missed)
256 variables.update(dict([(i, '') for i in missed])) 256 variables.update(dict([(i, '') for i in missed]))
257 257
258 return missing 258 return missing
300 300
301 def __init__(self, templates, output=None, interactive=True, **variables): 301 def __init__(self, templates, output=None, interactive=True, **variables):
302 302
303 assert templates, "No templates given!" 303 assert templates, "No templates given!"
304 304
305 self.interactive = True 305 self.interactive = interactive
306 self._templates = templates[:] 306 self._templates = templates[:]
307 self.templates = [] 307 self.templates = []
308 self.output = output 308 self.output = output
309 for template in templates: 309 for template in templates:
310 # TODO: check if the template is a [e.g] PasteScript.template entry point 310 # TODO: check if the template is a [e.g] PasteScript.template entry point