Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@staticmethod
def _flatten_append(l, x):
if x is None:
pass
elif isinstance(x, tag):
l.append(x.element)
elif isinstance(x, _Element):
l.append(x)
elif isinstance(x,list) or isinstance(x,tuple):
for y in x:
tag._flatten_append(l, y)
else:
if len(l):
l[-1].tail = (l[-1].tail or u'') + unicode(x)
else:
l.text = (l.text or u'') + unicode(x)