Mercurial > hg > MakeItSo
comparison makeitso/makeitso.py @ 63:b91133e3b02d
override get_variables for API template; could instead do this in the ctor, alternately
| author | Jeff Hammel <jhammel@mozilla.com> |
|---|---|
| date | Thu, 06 Jan 2011 17:58:34 -0800 |
| parents | 728cae02a6ed |
| children | 7909dfaef33b |
comparison
equal
deleted
inserted
replaced
| 62:30100690ad3f | 63:b91133e3b02d |
|---|---|
| 132 # TODO: automagically tell if the program is interactive or not | 132 # TODO: automagically tell if the program is interactive or not |
| 133 self.interactive = interactive | 133 self.interactive = interactive |
| 134 | 134 |
| 135 tempita.Template.__init__(self, content, name=name) | 135 tempita.Template.__init__(self, content, name=name) |
| 136 | 136 |
| 137 def get_variables(self, **variables): | |
| 138 """the template's augmented variable set""" | |
| 139 vars = self.defaults.copy() | |
| 140 vars.update(variables) | |
| 141 return vars | |
| 142 | |
| 137 def missing(self, **variables): | 143 def missing(self, **variables): |
| 138 """return additional variables needed""" | 144 """return additional variables needed""" |
| 139 vars = self.get_variables(**variables) | 145 vars = self.get_variables(**variables) |
| 140 missing = set([]) | 146 missing = set([]) |
| 141 while True: | 147 while True: |
| 145 except NameError, e: | 151 except NameError, e: |
| 146 missed = get_missing(e) | 152 missed = get_missing(e) |
| 147 missing.add(missed) | 153 missing.add(missed) |
| 148 vars[missed] = '' | 154 vars[missed] = '' |
| 149 return missing | 155 return missing |
| 150 | |
| 151 def get_variables(self, **variables): | |
| 152 vars = self.defaults.copy() | |
| 153 vars.update(variables) | |
| 154 return vars | |
| 155 | 156 |
| 156 def check_missing(self, vars): | 157 def check_missing(self, vars): |
| 157 """ | 158 """ |
| 158 check for missing variables and, if applicable, | 159 check for missing variables and, if applicable, |
| 159 update them from the command line | 160 update them from the command line |
