def replace_entities(self, html):
def fixup(text):<EOL><INDENT>"""<STR_LIT>"""<EOL>text = text.group(<NUM_LIT:0>)<EOL>if text[:<NUM_LIT:2>] == "<STR_LIT>":<EOL><INDENT>try:<EOL><INDENT>if text[:<NUM_LIT:3>] == "<STR_LIT>":<EOL><INDENT>return chr(int(text[<NUM_LIT:3>:-<NUM_LIT:1>], <NUM_LIT:16>))<EOL><DEDENT>else:<EOL><INDENT>return chr(int(text[<NUM_LIT:2>:-<NUM_LIT:1>]))<EOL><DEDENT><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>text = chr(htmlentitydefs.name2codepoint[text[<NUM_LIT:1>:-<NUM_LIT:1>]])<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return text  <EOL><DEDENT>return re.sub(r"<STR_LIT>", fixup, html)<EOL>
Replace htmlentities with unicode characters
@Params
html - html source to replace entities in
@Returns
String html with entities replaced