'Update the adblock block lists.
This updates `~/.local/share/qutebrowser/blocked-hosts` with downloaded
host lists and re-reads `~/.config/qutebrowser/blocked-hosts`.'

@cmdutils.register(instance='host-blocker')
def adblock_update(self):

    self._read_hosts_file(self._config_hosts_file, self._config_blocked_hosts)
    self._blocked_hosts = set()
    self._done_count = 0
    urls = config.get('content', 'host-block-lists')
    download_manager = objreg.get('qtnetwork-download-manager', scope='window', window='last-focused')
    if (urls is None):
        return
    for url in urls:
        if (url.scheme() == 'file'):
            try:
                fileobj = open(url.path(), 'rb')
            except OSError as e:
                message.error('adblock:    Error    while    reading    {}:    {}'.format(url.path(), e.strerror))
                continue
            download = FakeDownload(fileobj)
            self._in_progress.append(download)
            self.on_download_finished(download)
        else:
            fobj = io.BytesIO()
            fobj.name = ('adblock:    ' + url.host())
            target = downloads.FileObjDownloadTarget(fobj)
            download = download_manager.get(url, target=target, auto_remove=True)
            self._in_progress.append(download)
            download.finished.connect(functools.partial(self.on_download_finished, download))
