comparison makeitso/template.py @ 75:ec35e5763b52

* fix with assemble function * add a repr to variables
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 07 Jan 2011 18:18:42 -0800
parents d16823fd8c4a
children d4184945f8a8
comparison
equal deleted inserted replaced
74:d16823fd8c4a 75:ec35e5763b52
48 if self.default: 48 if self.default:
49 return 'Enter %s [DEFAULT: %s]:' % (description, repr(self.default)) 49 return 'Enter %s [DEFAULT: %s]:' % (description, repr(self.default))
50 else: 50 else:
51 return 'Enter %s:' % description 51 return 'Enter %s:' % description
52 52
53 def __repr__(self):
54 return "Variable(name='%s')" % self.name
55
53 def assemble(*args): 56 def assemble(*args):
54 names = set() 57 names = set()
55 retval = [] 58 retval = []
56 for arg in args: 59 for arg in args:
57 if issubclass(arg, MakeItSoTemplate): 60 if issubclass(arg, MakeItSoTemplate):
58 arg = arg.vars 61 arg = arg.vars
59 for variable in arg: 62 for variable in arg:
60 if variable.name in names: 63 if variable.name in names:
61 continue 64 continue
62 retval.append(variable.copy()) 65 retval.append(variable.copy())
66 names.add(variable.name)
63 return retval 67 return retval
64 68
65 class MakeItSoTemplate(ContentTemplate): 69 class MakeItSoTemplate(ContentTemplate):
66 """API template for MakeItSo""" 70 """API template for MakeItSo"""
67 71