def parse(filename):
for event, elt in et.iterparse(filename, events= ('<STR_LIT:start>', '<STR_LIT:end>', '<STR_LIT>', '<STR_LIT>'), huge_tree=True):<EOL><INDENT>if event == '<STR_LIT:start>':<EOL><INDENT>obj = _elt2obj(elt)<EOL>obj['<STR_LIT:type>'] = ENTER<EOL>yield obj<EOL>if elt.text:<EOL><INDENT>yield {'<STR_LIT:type>': TEXT, '<STR_LIT:text>': elt.text}<EOL><DEDENT><DEDENT>elif event == '<STR_LIT:end>':<EOL><INDENT>yield {'<STR_LIT:type>': EXIT}<EOL>if elt.tail:<EOL><INDENT>yield {'<STR_LIT:type>': TEXT, '<STR_LIT:text>': elt.tail}<EOL><DEDENT>elt.clear()<EOL><DEDENT>elif event == '<STR_LIT>':<EOL><INDENT>yield {'<STR_LIT:type>': COMMENT, '<STR_LIT:text>': elt.text}<EOL><DEDENT>elif event == '<STR_LIT>':<EOL><INDENT>yield {'<STR_LIT:type>': PI, '<STR_LIT:text>': elt.text}<EOL><DEDENT>else:<EOL><INDENT>assert False, (event, elt)<EOL><DEDENT><DEDENT>
Parses file content into events stream