def download_file(self, path, setting):
        version_file = self.settings['base_url'].format(self.selected_version())

        sdk_build_setting = self.get_setting('sdk_build')
        sdk_build = sdk_build_setting.value

        location = self.get_setting('download_dir').value

        versions = re.findall('v(\d+)\.(\d+)\.(\d+)', path)[0]

        minor = int(versions[1])
        if minor >= 12:
            path = path.replace('node-webkit', 'nwjs')

        if minor >= 13 and sdk_build:
            path = utils.replace_right(path, 'nwjs', 'nwjs-sdk', 1)

        self.progress_text = u'Downloading {}'.format(path.replace(version_file, ''))

        url = QUrl(path)
        file_name = setting.save_file_path(self.selected_version(), location, sdk_build)

        archive_exists = QFile.exists(file_name)

        forced = self.get_setting('force_download').value

        if archive_exists and not forced:
            self.continue_downloading_or_extract()
            return

        self.out_file = QFile(file_name)
        if not self.out_file.open(QIODevice.WriteOnly):
            error = self.out_file.error().name
            self.show_error(u'Unable to save the file {}: {}.'.format(file_name,
                                                                     error))
            self.out_file = None
            self.enable_ui()
            return

        mode = QHttp.ConnectionModeHttp
        port = url.port()
        if port == -1:
            port = 0
        self.http.setHost(url.host(), mode, port)
        self.http_request_aborted = False

        path = QUrl.toPercentEncoding(url.path(), "!$&'()*+,;=:@/")
        if path:
            path = str(path)
        else:
            path = u'/'

        # Download the file.
        self.http_get_id = self.http.get(path, self.out_file)
dataset/ETHPy150Open jyapayne/Web2Executable/main.py/MainWindow.download_file/original