comparison makeitso/makeitso.py @ 94:b6a46332cced

allow Polytemplates to take template objects
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 11 Jan 2011 07:33:59 -0800
parents d5da38fabdf7
children 80a57bf2b7f4
comparison
equal deleted inserted replaced
93:d5da38fabdf7 94:b6a46332cced
322 """template for several files/directories""" 322 """template for several files/directories"""
323 323
324 def __init__(self, templates, interactive=True, variables=None): 324 def __init__(self, templates, interactive=True, variables=None):
325 325
326 self.interactive = interactive 326 self.interactive = interactive
327 self._templates = templates[:]
328 self.templates = [] 327 self.templates = []
329 for template in templates: 328 for template in templates:
330 # TODO: check if the template is a [e.g] PasteScript.template entry point 329 if isinstance(template, basestring):
331 if os.path.isdir(template): 330 # TODO: check if the template is a [e.g] PasteScript.template entry point
332 self.templates.append(DirectoryTemplate(template, interactive=self.interactive, variables=variables)) 331 if os.path.isdir(template):
332 self.templates.append(DirectoryTemplate(template, interactive=self.interactive, variables=variables))
333 else:
334 self.templates.append(URITemplate(template, interactive=self.interactive, variables=variables))
333 else: 335 else:
334 self.templates.append(URITemplate(template, interactive=self.interactive, variables=variables)) 336 # assume the template is an object that conforms to the API
337 self.templates.append(template)
335 338
336 def missing(self, **variables): 339 def missing(self, **variables):
337 vars = variables.copy() 340 vars = variables.copy()
338 missing = set([]) 341 missing = set([])
339 for template in self.templates: 342 for template in self.templates: