192 """Expand list of templates to node tuple |
192 """Expand list of templates to node tuple |
193 |
193 |
194 >>> def f(tree): |
194 >>> def f(tree): |
195 ... print prettyformat(_unnesttemplatelist(tree)) |
195 ... print prettyformat(_unnesttemplatelist(tree)) |
196 >>> f(('template', [])) |
196 >>> f(('template', [])) |
197 ('string', '') |
197 (string '') |
198 >>> f(('template', [('string', 'foo')])) |
198 >>> f(('template', [('string', 'foo')])) |
199 ('string', 'foo') |
199 (string 'foo') |
200 >>> f(('template', [('string', 'foo'), ('symbol', 'rev')])) |
200 >>> f(('template', [('string', 'foo'), ('symbol', 'rev')])) |
201 (template |
201 (template |
202 ('string', 'foo') |
202 (string 'foo') |
203 ('symbol', 'rev')) |
203 (symbol 'rev')) |
204 >>> f(('template', [('symbol', 'rev')])) # template(rev) -> str |
204 >>> f(('template', [('symbol', 'rev')])) # template(rev) -> str |
205 (template |
205 (template |
206 ('symbol', 'rev')) |
206 (symbol 'rev')) |
207 >>> f(('template', [('template', [('string', 'foo')])])) |
207 >>> f(('template', [('template', [('string', 'foo')])])) |
208 ('string', 'foo') |
208 (string 'foo') |
209 """ |
209 """ |
210 if not isinstance(tree, tuple): |
210 if not isinstance(tree, tuple): |
211 return tree |
211 return tree |
212 op = tree[0] |
212 op = tree[0] |
213 if op != 'template': |
213 if op != 'template': |