#NEWLINE# def __get__( self , document , owner ) : #NEWLINE# #INDENT# if ( document is None ) : #NEWLINE# #INDENT# return self #NEWLINE# #UNINDENT# if hasattr ( document , '_element' ) : #NEWLINE# #INDENT# return document . _element #NEWLINE# #UNINDENT# def traverse( node , parent = None ) : #NEWLINE# #INDENT# if ( parent is not None ) : #NEWLINE# #INDENT# elem = ElementTree . SubElement ( parent , node . tag ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# elem = ElementTree . Element ( node . tag ) #NEWLINE# #UNINDENT# elem . text = node . text #NEWLINE# elem . tail = node . tail #NEWLINE# for attr in node . attributes : #NEWLINE# #INDENT# elem . attrib [ attr . name ] = attr . value #NEWLINE# #UNINDENT# for child in node . children : #NEWLINE# #INDENT# traverse ( child , parent = elem ) #NEWLINE# #UNINDENT# return elem #NEWLINE# #UNINDENT# document . _element = ElementTree . ElementTree ( traverse ( document . _root ) ) #NEWLINE# return document . _element