def is_article(self, response, url):
        """
        Tests if the given response is an article by calling and checking
        the heuristics set in config.cfg and sitelist.json

        :param obj response: The response of the site.
        :param str url: The base_url (needed to get the site-specific config
                        from the JSON-file)
        :return bool: true if the heuristics match the site as an article
        """
        site = self.__sites_object[url]
        heuristics = self.__get_enabled_heuristics(url)

        self.log.info("Checking site: %s", response.url)

        statement = self.__get_condition(url)
        self.log.debug("Condition (original): %s", statement)

        for heuristic, condition in heuristics.items():
            heuristic_func = getattr(self, heuristic)
            result = heuristic_func(response, site)
            check = self.__evaluate_result(result, condition)
            statement = re.sub(r"\b%s\b" % heuristic, str(check), statement)

            self.log.debug("Checking heuristic (%s)"
                           " result (%s) on condition (%s): %s",
                           heuristic, result, condition, check)

        self.log.debug("Condition (evaluated): %s", statement)
        is_article = eval(statement)
        self.log.debug("Article accepted: %s", is_article)
        return is_article
def is_article ( self , response , url ) : site = self . __sites_object [ url ] heuristics = self . __get_enabled_heuristics ( url ) self . log . info ( "Checking site: %s" , response . url ) statement = self . __get_condition ( url ) self . log . debug ( "Condition (original): %s" , statement ) for heuristic , condition in heuristics . items ( ) : heuristic_func = getattr ( self , heuristic ) result = heuristic_func ( response , site ) check = self . __evaluate_result ( result , condition ) statement = re . sub ( r"\b%s\b" % heuristic , str ( check ) , statement ) self . log . debug ( "Checking heuristic (%s)" " result (%s) on condition (%s): %s" , heuristic , result , condition , check ) self . log . debug ( "Condition (evaluated): %s" , statement ) is_article = eval ( statement ) self . log . debug ( "Article accepted: %s" , is_article ) return is_article
Tests if the given response is an article by calling and checking
        the heuristics set in config.cfg and sitelist.json

        :param obj response: The response of the site.
        :param str url: The base_url (needed to get the site-specific config
                        from the JSON-file)
        :return bool: true if the heuristics match the site as an article