Ejemplo n.º 1
0
 def __init__(self,
              *,
              data_dir: pathlib.Path,
              has_basedir: bool = False) -> None:
     self.enabled = _should_be_used()
     self._has_basedir = has_basedir
     self._cache_path = data_dir / "adblock-cache.dat"
     self._engine = adblock.Engine(adblock.FilterSet())
Ejemplo n.º 2
0
    def adblock_update(self) -> blockutils.BlocklistDownloads:
        """Update the adblock block lists."""
        logger.info("Downloading adblock filter lists...")

        filter_set = adblock.FilterSet()
        dl = blockutils.BlocklistDownloads(config.val.content.blocking.adblock.lists)
        dl.single_download_finished.connect(
            functools.partial(self._on_download_finished, filter_set=filter_set)
        )
        dl.all_downloads_finished.connect(
            functools.partial(self._on_lists_downloaded, filter_set=filter_set)
        )
        dl.initiate()
        return dl
Ejemplo n.º 3
0
 def __init__(self, *, data_dir: pathlib.Path, has_basedir: bool = False) -> None:
     self.enabled = _should_be_used()
     self._has_basedir = has_basedir
     self._cache_path = data_dir / "adblock-cache.dat"
     try:
         self._engine = adblock.Engine(adblock.FilterSet())
     except AttributeError:
         # this should never happen - let's get some infos if it does
         logger.debug(f"adblock module: {adblock}")
         dist = version.distribution()
         if (dist is not None and
                 dist.parsed == version.Distribution.arch and
                 hasattr(adblock, "__file__")):
             proc = subprocess.run(
                 ['pacman', '-Qo', adblock.__file__],
                 stdout=subprocess.PIPE,
                 universal_newlines=True,
                 check=False,
             )
             logger.debug(proc.stdout)
         raise