green-spider/rating/favicon.py
Marian Steinbach 04a1e98b79
Prüfe Existenz von /favicon.ico und werte dies ebenso wie ein Icon, das im HTML Head verlinkt ist (#115)
* Fix full JSON export

* Update ignore list

* Update README

* Check for /favicon.ico and rate it as icon available

* Remove broken cookies test
2019-05-05 22:26:41 +02:00

39 lines
1,002 B
Python

"""
This gives a score if the site has an icon.
"""
from rating.abstract_rater import AbstractRater
class Rater(AbstractRater):
rating_type = 'boolean'
default_value = False
depends_on_checks = ['html_head', 'load_favicons']
max_score = 1
def __init__(self, check_results):
super().__init__(check_results)
def rate(self):
value = self.default_value
score = 0
for url in self.check_results['html_head']:
if self.check_results['html_head'][url]['link_icon'] is not None:
value = True
score = self.max_score
break
# /favicon.ico as fall back
if url in self.check_results['load_favicons']:
value = True
score = self.max_score
break
return {
'type': self.rating_type,
'value': value,
'score': score,
'max_score': self.max_score,
}