How to use the kibitzr.fetcher.loader.URLPromoter function in kibitzr

To help you get started, we’ve selected a few kibitzr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kibitzr / kibitzr / kibitzr / fetcher / loader.py View on Github external
def is_applicable(cls, conf):
        """Return whether this promoter is applicable for given conf"""
        return all((
            URLPromoter.is_applicable(conf),
            cls.needs_firefox(conf),
        ))
github kibitzr / kibitzr / kibitzr / fetcher / loader.py View on Github external
def is_applicable(cls, conf):
        """Return whether this promoter is applicable for given conf"""
        return all((
            URLPromoter.is_applicable(conf),
            not cls.needs_firefox(conf),
        ))

    def fetch(self):
        from .simple import requests_fetcher
        super(RequestsPromoter, self).fetch()
        if not self._fetcher:
            self._fetcher = requests_fetcher(self.conf)
        return self._fetcher()


class FirefoxPromoter(URLPromoter):

    PRIORITY = 15

    @classmethod
    def is_applicable(cls, conf):
        """Return whether this promoter is applicable for given conf"""
        return all((
            URLPromoter.is_applicable(conf),
            cls.needs_firefox(conf),
        ))

    def fetch(self):
        from .browser.fetcher import firefox_fetcher
        super(FirefoxPromoter, self).fetch()
        return firefox_fetcher(self.conf)
github kibitzr / kibitzr / kibitzr / fetcher / loader.py View on Github external
"""Return whether this promoter is applicable for given conf"""
        return bool(conf.get('url'))

    def log_announcement(self):
        logger.info(u"Fetching %s at %s",
                    self.conf['name'], self.conf['url'])

    @staticmethod
    def needs_firefox(conf):
        return any(
            conf.get(key)
            for key in ('delay', 'scenario', 'form')
        )


class RequestsPromoter(URLPromoter):

    PRIORITY = 5  # default fallback

    def __init__(self, conf):
        super(RequestsPromoter, self).__init__(conf)
        self._fetcher = None

    @classmethod
    def is_applicable(cls, conf):
        """Return whether this promoter is applicable for given conf"""
        return all((
            URLPromoter.is_applicable(conf),
            not cls.needs_firefox(conf),
        ))

    def fetch(self):