def fixup_pem_file(path, actual_errors): """Updates the ERRORS block in the test .pem file""" contents = read_file_to_string(path) m = errors_block_regex.search(contents) if not m: contents += "\n" + common.text_data_to_pem("ERRORS", actual_errors) else: contents = replace_string(contents, m.start(1), m.end(1), common.text_data_to_pem("ERRORS", actual_errors)) # Update the file. write_string_to_file(contents, path)
def fixup_pem_file(path, actual_errors): """Updates the ERRORS block in the test .pem file""" contents = read_file_to_string(path) m = errors_block_regex.search(contents) if not m: contents += '\n' + common.text_data_to_pem('ERRORS', actual_errors) else: contents = replace_string(contents, m.start(1), m.end(1), common.text_data_to_pem('ERRORS', actual_errors)) # Update the file. write_string_to_file(contents, path)