<s> from difflib import SequenceMatcher <EOL> def sequence_matcher ( old , new ) : <EOL> """<STR_LIT>""" <EOL> sm = SequenceMatcher ( None , list ( old ) , list ( new ) ) <EOL> return sm . get_opcodes ( ) <EOL> def apply ( ops , old , new ) : <EOL> """<STR_LIT>""" <EOL> for code , a_start , a_end , b_start , b_end in ops : <EOL> if code == "<STR_LIT>" : <EOL> for t in new [ b_start : b_end ] : <EOL> yield t <EOL> elif code == "<STR_LIT:replace>" : <EOL> for t in new [ b_start : b_end ] : <EOL> yield t <EOL> elif code == "<STR_LIT>" : <EOL> for t in old [ a_start : a_end ] : <EOL> yield t <EOL> elif code == "<STR_LIT>" : <EOL> pass <EOL> else : <EOL> assert False , "<STR_LIT>" + repr ( code ) </s>
