mirror of
https://github.com/netzbegruenung/green-spider.git
synced 2024-05-04 18:13:40 +02:00
Add the green power Rater class
This commit is contained in:
parent
27d5661dba
commit
4f626947d2
|
@ -20,6 +20,7 @@ from rating import responsive_layout
|
||||||
from rating import social_media_links
|
from rating import social_media_links
|
||||||
from rating import use_specific_fonts
|
from rating import use_specific_fonts
|
||||||
from rating import www_optional
|
from rating import www_optional
|
||||||
|
from rating import green_power
|
||||||
|
|
||||||
|
|
||||||
def calculate_rating(results):
|
def calculate_rating(results):
|
||||||
|
@ -47,6 +48,7 @@ def calculate_rating(results):
|
||||||
'SOCIAL_MEDIA_LINKS': social_media_links,
|
'SOCIAL_MEDIA_LINKS': social_media_links,
|
||||||
'USE_SPECIFIC_FONTS': use_specific_fonts,
|
'USE_SPECIFIC_FONTS': use_specific_fonts,
|
||||||
'WWW_OPTIONAL': www_optional,
|
'WWW_OPTIONAL': www_optional,
|
||||||
|
'GREEN_POWER': green_power,
|
||||||
}
|
}
|
||||||
|
|
||||||
output = {}
|
output = {}
|
||||||
|
|
31
rating/green_power.py
Normal file
31
rating/green_power.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
"""
|
||||||
|
This checks the result for an url using green power, and returns
|
||||||
|
a boolean based on whether it's using green power or not
|
||||||
|
"""
|
||||||
|
|
||||||
|
from rating.abstract_rater import AbstractRater
|
||||||
|
|
||||||
|
class Rater(AbstractRater):
|
||||||
|
|
||||||
|
rating_type = 'boolean'
|
||||||
|
default_value = False
|
||||||
|
depends_on_checks = ['green_power']
|
||||||
|
max_score = 1
|
||||||
|
|
||||||
|
def __init__(self, check_results):
|
||||||
|
super().__init__(check_results)
|
||||||
|
|
||||||
|
def rate(self):
|
||||||
|
value = self.default_value
|
||||||
|
score = 0
|
||||||
|
|
||||||
|
if check_results['green_power']:
|
||||||
|
value = True
|
||||||
|
score = self.max_score
|
||||||
|
|
||||||
|
return {
|
||||||
|
'type': self.rating_type,
|
||||||
|
'value': value,
|
||||||
|
'score': score,
|
||||||
|
'max_score': self.max_score,
|
||||||
|
}
|
Loading…
Reference in a new issue