def replace_string(resource, resources, file, string_to_insert_after, new_string):

    new_string = new_string.format(resources=resources, resource=resource, Resource=resource.title(), Resources=resources.title())

    with open(file, 'r+', encoding = "utf-8") as old_file:
        filedata = old_file.read()
    if filedata in string_to_insert_after:
        # replace the first occurrence
        new_filedata = filedata.replace(
            string_to_insert_after, new_string, 1)
        with open(file, 'w', encoding = "utf-8") as new_file:
            new_file.write(new_filedata)
            print("Updated", file)
    else:
        error_msg = """Unable to replace {string_to_insert_after}, with {new_string}
                      in file {file} """.format(string_to_insert_after=string_to_insert_after, new_string=new_string,
                                                 file=file)
        raise ReplaceError(error_msg)
dataset/ETHPy150Open Leo-G/Flask-Scaffold/scaffold/modules/replace_string.py/replace_string/swapped operands of `in`