Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if spl_current_page == 0: # on parent page
if spl_rows < max_lines_parent:
return
else: # on child page
# TODO: make this stay below the max, instead of going 1 row over the max
# will require some backtracking...
if spl_print_func.bytes_written < max_report_child_size:
return
spl_current_page += 1
filename = "%s-%s.html" % (mainname, spl_current_page)
if spl_current_page > 1:
# previous page was a child, close it
spl_print_func(templates.UD_TABLE_FOOTER % {"filename": html.escape(filename), "text": "load diff"}, force=True)
spl_print_exit(None, None, None)
# rotate to the next child page
context = spl_file_printer(directory, filename)
spl_print_enter(context, rotation_params)
spl_print_func(templates.UD_TABLE_HEADER)
try:
spl_print_func = print_func
spl_print_ctrl = None, rotation_params
truncated = not output_unified_diff_table(unified_diff, has_internal_linenos)
except:
if not spl_print_exit(*sys.exc_info()): raise
else:
spl_print_exit(None, None, None)
finally:
spl_print_ctrl = None
spl_print_func = None
if spl_current_page > 0:
noun = "pieces" if spl_current_page > 1 else "piece"
text = "load diff (%s %s%s)" % (spl_current_page, noun, (", truncated" if truncated else ""))
print_func(templates.UD_TABLE_FOOTER % {"filename": html.escape("%s-1.html" % mainname), "text": text}, force=True)
def output_header(css_url, print_func):
if css_url:
css_link = '' % css_url
else:
css_link = ''
print_func(templates.HEADER % {'title': html.escape(' '.join(sys.argv)),
'favicon': FAVICON_BASE64,
'css_link': css_link,
})
# special highlighted chars
elif c == "\t" and ponct == 1:
n = TABSIZE-(i%TABSIZE)
if n == 0:
n = TABSIZE
t.write('<span class="diffponct">\xbb</span>'+'\xa0'*(n-1))
elif c == " " and ponct == 1:
t.write('<span class="diffponct">\xb7</span>')
elif c == "\n" and ponct == 1:
t.write('<br><span class="diffponct">\</span>')
elif ord(c) < 32:
conv = u"\\x%x" % ord(c)
t.write('<em>%s</em>' % conv)
i += len(conv)
else:
t.write(html.escape(c))
i += 1
if WORDBREAK.count(c) == 1:
t.write('\u200b')
i = 0
if i > LINESIZE:
i = 0
t.write('\u200b')
return t.getvalue()
def output_difference(difference, print_func, css_url, directory, parents):
logger.debug('html output for %s', difference.source1)
sources = parents + [difference.source1]
print_func(u'<div class="difference">')
try:
print_func(u'<div class="diffheader">')
if difference.source1 == difference.source2:
print_func(u'<div class="diffcontrol">[−]</div>')
print_func(u'<div><span class="source">%s</span>'
% html.escape(difference.source1))
else:
print_func(u'<div class="diffcontrol diffcontrol-double">[−]</div>')
print_func(u'<div><span class="source">%s</span> vs.</div>'
% html.escape(difference.source1))
print_func(u'<div><span class="source">%s</span>'
% html.escape(difference.source2))
anchor = escape_anchor('/'.join(sources[1:]))
print_func(u' <a name="%s" href="#%s" class="anchor">\xb6</a>' % (anchor, anchor))
print_func(u"</div>")
if difference.comments:
print_func(u'<div class="comment">%s</div>'
% u'<br>'.join(map(html.escape, difference.comments)))
print_func(u"</div>")
if difference.unified_diff:
output_unified_diff(print_func, css_url, directory, difference.unified_diff, difference.has_internal_linenos)
for detail in difference.details:
output_difference(detail, print_func, css_url, directory, sources)
except PrintLimitReached:
logger.debug('print limit reached')
raise
finally:
print_func(u"</div>", force=True)</div>
def output_difference(difference, print_func, css_url, directory, parents):
logger.debug('html output for %s', difference.source1)
sources = parents + [difference.source1]
print_func(u'<div class="difference">')
try:
print_func(u'<div class="diffheader">')
if difference.source1 == difference.source2:
print_func(u'<div class="diffcontrol">[−]</div>')
print_func(u'<div><span class="source">%s</span>'
% html.escape(difference.source1))
else:
print_func(u'<div class="diffcontrol diffcontrol-double">[−]</div>')
print_func(u'<div><span class="source">%s</span> vs.</div>'
% html.escape(difference.source1))
print_func(u'<div><span class="source">%s</span>'
% html.escape(difference.source2))
anchor = escape_anchor('/'.join(sources[1:]))
print_func(u' <a name="%s" href="#%s" class="anchor">\xb6</a>' % (anchor, anchor))
print_func(u"</div>")
if difference.comments:
print_func(u'<div class="comment">%s</div>'
% u'<br>'.join(map(html.escape, difference.comments)))
print_func(u"</div>")
if difference.unified_diff:
output_unified_diff(print_func, css_url, directory, difference.unified_diff, difference.has_internal_linenos)
for detail in difference.details:
output_difference(detail, print_func, css_url, directory, sources)
except PrintLimitReached:
logger.debug('print limit reached')
raise</div></div>
def output_difference(difference, print_func, css_url, directory, parents):
logger.debug('html output for %s', difference.source1)
sources = parents + [difference.source1]
print_func(u'<div class="difference">')
try:
print_func(u'<div class="diffheader">')
if difference.source1 == difference.source2:
print_func(u'<div class="diffcontrol">[−]</div>')
print_func(u'<div><span class="source">%s</span>'
% html.escape(difference.source1))
else:
print_func(u'<div class="diffcontrol diffcontrol-double">[−]</div>')
print_func(u'<div><span class="source">%s</span> vs.</div>'
% html.escape(difference.source1))
print_func(u'<div><span class="source">%s</span>'
% html.escape(difference.source2))
anchor = escape_anchor('/'.join(sources[1:]))
print_func(u' <a name="%s" href="#%s" class="anchor">\xb6</a>' % (anchor, anchor))
print_func(u"</div>")
if difference.comments:
print_func(u'<div class="comment">%s</div>'
% u'<br>'.join(map(html.escape, difference.comments)))
print_func(u"</div>")
if difference.unified_diff:
output_unified_diff(print_func, css_url, directory, difference.unified_diff, difference.has_internal_linenos)
for detail in difference.details:</div></div>