mercurial/templater.py
changeset 29815 0d5cc0c18b4e
parent 29812 01f036f0e40b
child 29816 034412ca28c3
equal deleted inserted replaced
29814:cbf9984a7957 29815:0d5cc0c18b4e
   915 
   915 
   916 def _flatten(thing):
   916 def _flatten(thing):
   917     '''yield a single stream from a possibly nested set of iterators'''
   917     '''yield a single stream from a possibly nested set of iterators'''
   918     if isinstance(thing, str):
   918     if isinstance(thing, str):
   919         yield thing
   919         yield thing
       
   920     elif thing is None:
       
   921         pass
   920     elif not util.safehasattr(thing, '__iter__'):
   922     elif not util.safehasattr(thing, '__iter__'):
   921         if thing is not None:
   923         yield str(thing)
   922             yield str(thing)
       
   923     else:
   924     else:
   924         for i in thing:
   925         for i in thing:
   925             if isinstance(i, str):
   926             if isinstance(i, str):
   926                 yield i
   927                 yield i
       
   928             elif i is None:
       
   929                 pass
   927             elif not util.safehasattr(i, '__iter__'):
   930             elif not util.safehasattr(i, '__iter__'):
   928                 if i is not None:
   931                 yield str(i)
   929                     yield str(i)
   932             else:
   930             elif i is not None:
       
   931                 for j in _flatten(i):
   933                 for j in _flatten(i):
   932                     yield j
   934                     yield j
   933 
   935 
   934 def unquotestring(s):
   936 def unquotestring(s):
   935     '''unwrap quotes if any; otherwise returns unmodified string'''
   937     '''unwrap quotes if any; otherwise returns unmodified string'''