def appendTextElements(e, contentsList, se):
 def uconcat(text, newText, se):
  if (type(newText) != type(text)):
   if (type(text) is str):
    text = text.decode(se)
   else:
    newText = newText.decode(se)
  return (text + newText)
 e.text = ''
 lastElement = None
 for content in contentsList:
  if (not isinstance(content, Text)):
   newElement = content.toElement(se)
   if (newElement is None):
    continue
   lastElement = newElement
   lastElement.tail = ''
   e.append(lastElement)
  elif (lastElement is None):
   e.text = uconcat(e.text, content.text, se)
  else:
   lastElement.tail = uconcat(lastElement.tail, content.text, se)

def appendTextElements ( e , contentsList , se ) : def uconcat ( text , newText , se ) : if ( type ( newText ) != type ( text ) ) : if ( type ( text ) is str ) : text = text . decode ( se ) else : newText = newText . decode ( se ) return ( text + newText ) e . text = '' lastElement = None for content in contentsList : if ( not isinstance ( content , Text ) ) : newElement = content . toElement ( se ) if ( newElement is None ) : continue lastElement = newElement lastElement . tail = '' e . append ( lastElement ) elif ( lastElement is None ) : e . text = uconcat ( e . text , content . text , se ) else : lastElement . tail = uconcat ( lastElement . tail , content . text , se )
a helper function to convert text streams into the proper elements .