Commit d8d0d3b1 authored by Michal Čihař's avatar Michal Čihař

Better variable names

parent e8a470d4
...@@ -27,19 +27,20 @@ def html_diff(old, new): ...@@ -27,19 +27,20 @@ def html_diff(old, new):
''' '''
diff = SequenceMatcher(None, old, new) diff = SequenceMatcher(None, old, new)
result = [] result = []
for tag, i1, i2, j1, j2 in diff.get_opcodes(): for tag, oldpos1, oldpos2, newpos1, newpos2 in diff.get_opcodes():
if tag == 'replace': if tag == 'replace':
result.append( result.append(
'<del>%s</del><ins>%s</ins>' % (old[i1:i2], new[j1:j2]) '<del>%s</del><ins>%s</ins>' %
(old[oldpos1:oldpos2], new[newpos1:newpos2])
) )
elif tag == 'delete': elif tag == 'delete':
result.append( result.append(
'<del>%s</del>' % old[i1:i2] '<del>%s</del>' % old[oldpos1:oldpos2]
) )
elif tag == 'insert': elif tag == 'insert':
result.append( result.append(
'<ins>%s</ins>' % new[j1:j2] '<ins>%s</ins>' % new[newpos1:newpos2]
) )
elif tag == 'equal': elif tag == 'equal':
result.append(new[j1:j2]) result.append(new[newpos1:newpos2])
return ''.join(result) return ''.join(result)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment