mirror of
https://github.com/netzbegruenung/green-spider.git
synced 2024-05-06 02:43:42 +02:00
d0e3a4210f
* Fix rating for contact_link and social_media_link * Skip checks when dependencies not met
44 lines
1 KiB
Python
44 lines
1 KiB
Python
"""
|
|
Checks whether the pages has a link "Kontakt"
|
|
"""
|
|
|
|
from rating.abstract_rater import AbstractRater
|
|
|
|
class Rater(AbstractRater):
|
|
|
|
rating_type = 'boolean'
|
|
default_value = False
|
|
depends_on_checks = ['hyperlinks']
|
|
max_score = 1
|
|
|
|
def __init__(self, check_results):
|
|
super().__init__(check_results)
|
|
|
|
def rate(self):
|
|
value = self.default_value
|
|
score = 0
|
|
|
|
urls = 0
|
|
urls_with_contact_link = 0
|
|
|
|
for url in self.check_results['hyperlinks']:
|
|
|
|
urls += 1
|
|
|
|
for link in self.check_results['hyperlinks'][url]['links']:
|
|
if link['text'].lower() == 'kontakt':
|
|
urls_with_contact_link += 1
|
|
# make sure we only count 1 for this url
|
|
break
|
|
|
|
if urls > 0 and urls_with_contact_link == urls:
|
|
score = self.max_score
|
|
value = True
|
|
|
|
return {
|
|
'type': self.rating_type,
|
|
'value': value,
|
|
'score': score,
|
|
'max_score': self.max_score,
|
|
}
|