def tag_from_element(el):
tag = el.tag<EOL>namespace = None<EOL>if tag.startswith('<STR_LIT:{>'):<EOL><INDENT>namespace,tag = tag[<NUM_LIT:1>:].split('<STR_LIT:}>')<EOL><DEDENT>try:<EOL><INDENT>cls = globals()[tag.title()]<EOL>if not issubclass(cls, TagBase):<EOL><INDENT>raise KeyError()<EOL><DEDENT><DEDENT>except KeyError:<EOL><INDENT>raise ValueError("<STR_LIT>" % tag)<EOL><DEDENT>children = [tag_from_element(c) for c in el]<EOL>tag = cls(*children, **el.attrib)<EOL>tag.text = el.text<EOL>tag.tail = el.tail<EOL>if namespace:<EOL><INDENT>tag.attrib['<STR_LIT>'] = namespace<EOL><DEDENT>return tag<EOL>
Convert an Element into a Tag.

``el`` is an instance of ``Element``. Returns an instance of the
corresponding subclass of ``TagBase``.