comparison makeitso/template.py @ 64:c20277dbf8fa

closer to substitution
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 06 Jan 2011 18:04:58 -0800
parents b91133e3b02d
children 0152741621c1
comparison
equal deleted inserted replaced
63:b91133e3b02d 64:c20277dbf8fa
108 return vars 108 return vars
109 109
110 def missing(self, **variables): 110 def missing(self, **variables):
111 vars = self.get_variables(**variables) 111 vars = self.get_variables(**variables)
112 missing = set([]) 112 missing = set([])
113
114 # get known needed variables
115 for var in self.vars:
116 if var.name not in vars:
117 missing.add(var)
118
113 if self.look: 119 if self.look:
114 pass 120 # scan templates for other variables
115 else: 121 raise NotImplementedError
116 for var in self.vars: 122
117 if self.usedefaults: 123 return missing
118 import pdb; pdb.set_trace()
119 else:
120 pass
121 124
122 def pre(self, **variables): 125 def pre(self, **variables):
123 """do stuff before interpolation""" 126 """do stuff before interpolation"""
124 127
125 def substitute(self, **variables): 128 def substitute(self, **variables):
126 """do the substitution""" 129 """do the substitution"""
127 vars = self.get_variables(**variables) 130 vars = self.get_variables(**variables)
128 self.pre(**variables) 131 self.pre(**vars)
129 self.check_missing(vars) 132 self.check_missing(vars)
133
134 # do the substitution
135 PolyTemplate(self.templates,
136 output=self.output,
137 interactive=self.interactive,
138 variables = vars
139
140
130 self.post(**variables) 141 self.post(**variables)
131 142
132 def post(self, **variables): 143 def post(self, **variables):
133 """do stuff after interpolation""" 144 """do stuff after interpolation"""
134 145