def _render_change_replace_lines(self, differ, i1, i2, j1, j2, old_lines, new_lines): replace_new_lines = [] for i, j in zip(range(i1, i2), range(j1, j2)): old_line = old_lines[i] new_line = new_lines[j] parser = HTMLParser() old_regions, new_regions = \ get_line_changed_regions(parser.unescape(strip_tags(old_line)), parser.unescape(strip_tags(new_line))) old_line = highlightregion(old_line, old_regions) new_line = highlightregion(new_line, new_regions) yield ('<tr class="replace-old">' ' <td class="marker">~</td>' ' <td class="marker"> </td>' ' <td class="line rich-text">%s</td>' '</tr>' % old_line) replace_new_lines.append(new_line) for line in replace_new_lines: yield ('<tr class="replace-new">' ' <td class="marker"> </td>' ' <td class="marker">~</td>' ' <td class="line rich-text">%s</td>' '</tr>' % line)
def _render_change_replace_lines(self, differ, i1, i2, j1, j2, old_lines, new_lines): replace_new_lines = [] for i, j in zip(range(i1, i2), range(j1, j2)): old_line = old_lines[i] new_line = new_lines[j] parser = HTMLParser() old_regions, new_regions = \ get_line_changed_regions(parser.unescape(strip_tags(old_line)), parser.unescape(strip_tags(new_line))) old_line = highlightregion(old_line, old_regions) new_line = highlightregion(new_line, new_regions) yield ( '<tr class="replace-old">' ' <td class="marker">~</td>' ' <td class="marker"> </td>' ' <td class="line rich-text">%s</td>' '</tr>' % old_line) replace_new_lines.append(new_line) for line in replace_new_lines: yield ( '<tr class="replace-new">' ' <td class="marker"> </td>' ' <td class="marker">~</td>' ' <td class="line rich-text">%s</td>' '</tr>' % line)
def end_string(self): h = HTMLParser() data = h.unescape(force_text(self.getData())) if data == '__PyNone__': self.addObject(None) else: self.addObject(data)
def test_is_html_escaped(self): """Unescape the escaped response to see if it's the original content""" h = HTMLParser() content = '*****@*****.**' self.assertEqual(h.unescape( force_text(self.middleware.process_response(None, HttpResponse(content)).content)), content)
def unescape(s): return HTMLParser().unescape(s)
def plain_text(html): h = HTMLParser() return h.unescape(strip_tags(html))
def __init__(self): HTMLParser.__init__(self) self.html = str()
def __init__(self): HTMLParser.__init__(self, convert_charrefs=False) self.html = str()
def end_data(self): h = HTMLParser() value = h.unescape(force_text( plistlib.Data.fromBase64(self.getData()).data )) self.addObject(value)
def setUpClass(cls): super(QuerystringTagTests, cls).setUpClass() cls.html_parser = HTMLParser()
def __init__(self, *args, **kwargs): HTMLParser.__init__(self, *args, **kwargs) self.is_idle = 0 self.last_abbr = None self.last_link = None self.text_fragments = []
def __init__(self, *args, **kwargs): HTMLParser.__init__(self, *args, **kwargs) self.open_tags = []
def end_data(self): h = HTMLParser() value = h.unescape( force_text(plistlib.Data.fromBase64(self.getData()).data)) self.addObject(value)