def replace_lines(html_file, transformed):
result = []<EOL>with codecs.open(html_file, '<STR_LIT:r>', '<STR_LIT:utf-8>') as input_file:<EOL><INDENT>for line in input_file:<EOL><INDENT>line = re.sub(r'<STR_LIT>', '<STR_LIT:">', line)<EOL>for attr, value, new_link in transformed:<EOL><INDENT>if attr in line and value in line:<EOL><INDENT>new_line = line.replace(value, new_link)<EOL>result.append(new_line)<EOL>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>result.append(line)<EOL><DEDENT><DEDENT>return '<STR_LIT>'.join(result)<EOL><DEDENT>
Replace lines in the old file with the transformed lines.