def adjusted_ops(opcodes):
while opcodes:<EOL><INDENT>op = opcodes.pop(<NUM_LIT:0>)<EOL>tag, i1, i2, j1, j2 = op<EOL>shift = <NUM_LIT:0><EOL>if tag == '<STR_LIT>':<EOL><INDENT>continue<EOL><DEDENT>if tag == '<STR_LIT:replace>':<EOL><INDENT>opcodes = [<EOL>('<STR_LIT>', i1, i2, j1, j1),<EOL>('<STR_LIT>', i2, i2, j1, j2),<EOL>] + opcodes<EOL>continue<EOL><DEDENT>yield op<EOL>if tag == '<STR_LIT>':<EOL><INDENT>shift = -(i2 - i1)<EOL><DEDENT>elif tag == '<STR_LIT>':<EOL><INDENT>shift = +(j2 - j1)<EOL><DEDENT>new_opcodes = []<EOL>for tag, i1, i2, j1, j2 in opcodes:<EOL><INDENT>new_opcodes.append((<EOL>tag,<EOL>i1 + shift,<EOL>i2 + shift,<EOL>j1,<EOL>j2,<EOL>))<EOL><DEDENT>opcodes = new_opcodes<EOL><DEDENT>
Iterate through opcodes, turning them into a series of insert and delete
operations, adjusting indices to account for the size of insertions and
deletions.

>>> def sequence_opcodes(old, new): return difflib.SequenceMatcher(a=old, b=new).get_opcodes()
>>> list(adjusted_ops(sequence_opcodes('abc', 'b')))
[('delete', 0, 1, 0, 0), ('delete', 1, 2, 1, 1)]
>>> list(adjusted_ops(sequence_opcodes('b', 'abc')))
[('insert', 0, 0, 0, 1), ('insert', 2, 2, 2, 3)]
>>> list(adjusted_ops(sequence_opcodes('axxa', 'aya')))
[('delete', 1, 3, 1, 1), ('insert', 1, 1, 1, 2)]
>>> list(adjusted_ops(sequence_opcodes('axa', 'aya')))
[('delete', 1, 2, 1, 1), ('insert', 1, 1, 1, 2)]
>>> list(adjusted_ops(sequence_opcodes('ab', 'bc')))
[('delete', 0, 1, 0, 0), ('insert', 1, 1, 1, 2)]
>>> list(adjusted_ops(sequence_opcodes('bc', 'ab')))
[('insert', 0, 0, 0, 1), ('delete', 2, 3, 2, 2)]