def parse_html(html):
 parser = Parser()
 parser.feed(html)
 parser.close()
 document = parser.root
 document.finalize()
 if (len(document.children) == 1):
  if (not isinstance(document.children[0], six.string_types)):
   document = document.children[0]
 return document

def parse_html ( html ) : parser = Parser ( ) parser . feed ( html ) parser . close ( ) document = parser . root document . finalize ( ) if ( len ( document . children ) == 1 ) : if ( not isinstance ( document . children [ 0 ] , six . string_types ) ) : document = document . children [ 0 ] return document
parses a string .