def _install_file(name_in, name_out, patches):
    """ Install a file and return a copy of its contents. """
    with open(name_in) as f:
        data = f.read()
    for patch_name, patch in patches.items():
        data = data.replace(patch_name, patch)
    with open(name_out, 'w') as f:
        f.write(data)
    return data
