#NEWLINE# def prepare_payload( self , payload ) : #NEWLINE# #INDENT# root = ET . Element ( 'tile' ) #NEWLINE# visual = ET . SubElement ( root , 'visual' ) #NEWLINE# binding = ET . SubElement ( visual , 'binding' ) #NEWLINE# binding . attrib [ 'template' ] = payload [ 'template' ] #NEWLINE# if ( 'text' in payload ) : #NEWLINE# #INDENT# count = 1 #NEWLINE# for t in payload [ 'text' ] : #NEWLINE# #INDENT# el = ET . SubElement ( binding , 'text' ) #NEWLINE# el . text = t #NEWLINE# el . attrib [ 'id' ] = ( '%d' % count ) #NEWLINE# count = ( count + 1 ) #NEWLINE# #UNINDENT# #UNINDENT# if ( 'image' in el ) : #NEWLINE# #INDENT# count = 1 #NEWLINE# for image in payload [ 'image' ] : #NEWLINE# #INDENT# el = ET . SubElement ( binding , 'img' ) #NEWLINE# el . attrib [ 'id' ] = ( '%d' % count ) #NEWLINE# el . attrib [ 'src' ] = ( '%s' % image ) #NEWLINE# count = ( count + 1 ) #NEWLINE# #UNINDENT# #UNINDENT# return self . serialize_tree ( ET . ElementTree ( root ) )