133 self._ui.write("\n }") |
133 self._ui.write("\n }") |
134 def end(self): |
134 def end(self): |
135 baseformatter.end(self) |
135 baseformatter.end(self) |
136 self._ui.write("\n]\n") |
136 self._ui.write("\n]\n") |
137 |
137 |
|
138 class templateformatter(baseformatter): |
|
139 def __init__(self, ui, topic, opts): |
|
140 baseformatter.__init__(self, ui, topic, opts) |
|
141 self._topic = topic |
|
142 self._t = gettemplater(ui, topic, opts.get('template', '')) |
|
143 def _showitem(self): |
|
144 g = self._t(self._topic, **self._item) |
|
145 self._ui.write(templater.stringify(g)) |
|
146 |
138 def lookuptemplate(ui, topic, tmpl): |
147 def lookuptemplate(ui, topic, tmpl): |
139 # looks like a literal template? |
148 # looks like a literal template? |
140 if '{' in tmpl: |
149 if '{' in tmpl: |
141 return tmpl, None |
150 return tmpl, None |
142 |
151 |
185 elif template == "pickle": |
194 elif template == "pickle": |
186 return pickleformatter(ui, topic, opts) |
195 return pickleformatter(ui, topic, opts) |
187 elif template == "debug": |
196 elif template == "debug": |
188 return debugformatter(ui, topic, opts) |
197 return debugformatter(ui, topic, opts) |
189 elif template != "": |
198 elif template != "": |
190 raise util.Abort(_("custom templates not yet supported")) |
199 return templateformatter(ui, topic, opts) |
191 elif ui.configbool('ui', 'formatdebug'): |
200 elif ui.configbool('ui', 'formatdebug'): |
192 return debugformatter(ui, topic, opts) |
201 return debugformatter(ui, topic, opts) |
193 elif ui.configbool('ui', 'formatjson'): |
202 elif ui.configbool('ui', 'formatjson'): |
194 return jsonformatter(ui, topic, opts) |
203 return jsonformatter(ui, topic, opts) |
195 return plainformatter(ui, topic, opts) |
204 return plainformatter(ui, topic, opts) |