def _load(self, path):
        try:
            import adblockparser
        except __HOLE__:
            log.msg('WARNING: https://github.com/scrapinghub/adblockparser '
                    'library is not available, filters are not loaded.')
            return

        for fname in os.listdir(path):
            if not fname.endswith('.txt'):
                continue
            fpath = os.path.join(path, fname)
            name = fname[:-len('.txt')]

            if not os.path.isfile(fpath):
                continue

            if self.verbosity >= 1:
                log.msg("Loading filter %s" % name)

            with open(fpath, 'rb') as f:
                lines = [line.decode('utf8').strip() for line in f]

            rules = adblockparser.AdblockRules(
                lines,
                supported_options=self.supported_options,
                skip_unsupported_rules=False,
                max_mem=512*1024*1024,  # this doesn't actually use 512M
            )
            filters_num = len(rules.rules)

            if self.verbosity >= 2:
                log.msg("%d rule(s) loaded for filter %s" % (filters_num, name))

            if not rules.uses_re2 and filters_num > self.RE2_WARN_THRESHOLD:
                log.msg('WARNING: a filter %s with %d rules loaded, but '
                        'pyre2 library is not installed. Matching may become '
                        'slow; installing https://github.com/axiak/pyre2 is '
                        'highly recommended.' % (name, filters_num))

            self.filters[name] = rules
dataset/ETHPy150Open scrapinghub/splash/splash/request_middleware.py/AdblockRulesRegistry._load