Exemple #1
0
 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)
Exemple #2
0
    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">&nbsp;</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">&nbsp;</td>'
                   ' <td class="marker">~</td>'
                   ' <td class="line rich-text">%s</td>'
                   '</tr>' % line)
Exemple #3
0
    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">&nbsp;</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">&nbsp;</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 end_string(self):
     h = HTMLParser()
     data = h.unescape(force_text(self.getData()))
     if data == '__PyNone__':
         self.addObject(None)
     else:
         self.addObject(data)
def plain_text(html):
    h = HTMLParser()
    return h.unescape(strip_tags(html))
 def end_data(self):
     h = HTMLParser()
     value = h.unescape(force_text(
         plistlib.Data.fromBase64(self.getData()).data
     ))
     self.addObject(value)
 def end_data(self):
     h = HTMLParser()
     value = h.unescape(
         force_text(plistlib.Data.fromBase64(self.getData()).data))
     self.addObject(value)
def plain_text(html):
    h = HTMLParser()
    return h.unescape(strip_tags(html))