def adblock_update(self) -> None: """Update the adblock block lists.""" self._read_hosts_file(self._config_hosts_file, self._config_blocked_hosts) self._blocked_hosts = set() self._done_count = 0 for url in config.val.content.host_blocking.lists: if url.scheme() == 'file': filename = url.toLocalFile() if os.path.isdir(filename): for entry in os.scandir(filename): if entry.is_file(): self._import_local(entry.path) else: self._import_local(filename) else: download = downloads.download_temp(url) self._in_progress.append(download) download.finished.connect( functools.partial(self._on_download_finished, download))
def adblock_update(self) -> None: """Update the adblock block lists.""" self._read_hosts_file(self._config_hosts_file, self._config_blocked_hosts) self._blocked_hosts = set() self._done_count = 0 for url in config.val.content.host_blocking.lists: if url.scheme() == 'file': filename = url.toLocalFile() if os.path.isdir(filename): for entry in os.scandir(filename): if entry.is_file(): self._import_local(entry.path) else: self._import_local(filename) else: download = downloads.download_temp(url) self._in_progress.append(download) download.finished.connect( functools.partial(self._on_download_finished, download))
def _download_blocklist_url(self, url: QUrl) -> None: """Take a blocklist url and queue it for download. Args: url: url to download """ if url.scheme() == "file": # The URL describes a local file on disk if the url scheme is # "file://". We handle those as a special case. filename = url.toLocalFile() if os.path.isdir(filename): for entry in os.scandir(filename): if entry.is_file(): self._import_local(entry.path) else: self._import_local(filename) else: download = downloads.download_temp(url) self._in_progress.append(download) download.finished.connect( functools.partial(self._on_download_finished, download))