def scan(xml):
if xml.tag is et.Comment:<EOL><INDENT>yield {'<STR_LIT:type>': COMMENT, '<STR_LIT:text>': xml.text}<EOL>return<EOL><DEDENT>if xml.tag is et.PI:<EOL><INDENT>if xml.text:<EOL><INDENT>yield {'<STR_LIT:type>': PI, '<STR_LIT:target>': xml.target, '<STR_LIT:text>': xml.text}<EOL><DEDENT>else:<EOL><INDENT>yield {'<STR_LIT:type>': PI, '<STR_LIT:target>': xml.target}<EOL><DEDENT>return<EOL><DEDENT>obj = _elt2obj(xml)<EOL>obj['<STR_LIT:type>'] = ENTER<EOL>yield obj<EOL>assert type(xml.tag) is str, xml<EOL>if xml.text:<EOL><INDENT>yield {'<STR_LIT:type>': TEXT, '<STR_LIT:text>': xml.text}<EOL><DEDENT>for c in xml:<EOL><INDENT>for x in scan(c): yield x<EOL>if c.tail:<EOL><INDENT>yield {'<STR_LIT:type>': TEXT, '<STR_LIT:text>': c.tail}<EOL><DEDENT><DEDENT>yield {'<STR_LIT:type>': EXIT}<EOL>
Converts XML tree to event generator