def METHOD_NAME(locale, scraper, engines):
    directory = os.path.join("SearchPlugins", locale)
    if not os.path.exists(directory):
        os.makedirs(directory)
    # Remove Bing.
    if 'bing' in engines: engines.remove('bing')
    # Always include DuckDuckGo.
    if "duckduckgo" not in engines:
        lastEngine = '~'
        for i, engine in reversed(list(enumerate(engines))):
            if i > 0 and "duckduckgo" < engine and engine < lastEngine and not engine.startswith("google"):
                lastEngine = engine
                continue
            engines.insert(i + 1, "duckduckgo")
            break
    for engine in engines:
        file = engine + ".xml"
        path = os.path.join(directory, file)
        downloadedFile = scraper.getFile(file)
        if downloadedFile == None:
            print("  skipping: %s..." % file)
            continue
        print("  downloading: %s..." % file)
        name, extension = os.path.splitext(file)
        # Apply iOS-specific overlays for this engine if they are defined.
        if extension == ".xml":
            engine = name.split("-")[0]
            overlay = overlayForEngine(engine)
            if overlay:
                plugin = etree.parse(downloadedFile)
                overlay.apply(plugin)
                contents = etree.tostring(plugin.getroot(), encoding="utf-8", pretty_print=True)
                with open(path, "w") as outfile:
                    outfile.write(contents)
                continue
        # Otherwise, just use the downloaded file as is.
        shutil.move(downloadedFile, path)