2018-10-03 11:05:42 +02:00
|
|
|
"""
|
|
|
|
The rating module contains the functionality to get calculate score for certain
|
|
|
|
criteria based on information gather by checks before.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
from rating import canonical_url
|
2018-11-20 22:47:34 +01:00
|
|
|
from rating import contact_link
|
2018-10-03 11:05:42 +02:00
|
|
|
from rating import favicon
|
|
|
|
from rating import feeds
|
|
|
|
from rating import https
|
|
|
|
from rating import no_network_errors
|
|
|
|
from rating import no_script_errors
|
2019-04-29 10:09:25 +02:00
|
|
|
from rating import no_third_party_cookies
|
2018-10-03 11:05:42 +02:00
|
|
|
from rating import reachable
|
|
|
|
from rating import resolvable
|
|
|
|
from rating import response_duration
|
|
|
|
from rating import responsive_layout
|
2018-11-20 22:47:34 +01:00
|
|
|
from rating import social_media_links
|
2018-10-03 11:05:42 +02:00
|
|
|
from rating import use_specific_fonts
|
|
|
|
from rating import www_optional
|
|
|
|
|
|
|
|
|
|
|
|
def calculate_rating(results):
|
|
|
|
"""
|
|
|
|
Calculates ratings for a number of criteria.
|
|
|
|
|
|
|
|
Params:
|
|
|
|
results - Results dictionary from checks
|
|
|
|
"""
|
|
|
|
|
|
|
|
# The raters to execute.
|
|
|
|
rating_modules = {
|
|
|
|
'CANONICAL_URL': canonical_url,
|
2018-11-20 22:47:34 +01:00
|
|
|
'CONTACT_LINK': contact_link,
|
2018-10-03 11:05:42 +02:00
|
|
|
'DNS_RESOLVABLE_IPV4': resolvable,
|
|
|
|
'FAVICON': favicon,
|
|
|
|
'FEEDS': feeds,
|
|
|
|
'HTTPS': https,
|
|
|
|
'HTTP_RESPONSE_DURATION': response_duration,
|
|
|
|
'NO_NETWORK_ERRORS': no_network_errors,
|
|
|
|
'NO_SCRIPT_ERRORS': no_script_errors,
|
2019-04-29 10:09:25 +02:00
|
|
|
'NO_THIRD_PARTY_COOKIES': no_third_party_cookies,
|
2018-10-03 11:05:42 +02:00
|
|
|
'RESPONSIVE': responsive_layout,
|
|
|
|
'SITE_REACHABLE': reachable,
|
2018-11-20 22:47:34 +01:00
|
|
|
'SOCIAL_MEDIA_LINKS': social_media_links,
|
2018-10-03 11:05:42 +02:00
|
|
|
'USE_SPECIFIC_FONTS': use_specific_fonts,
|
|
|
|
'WWW_OPTIONAL': www_optional,
|
|
|
|
}
|
|
|
|
|
|
|
|
output = {}
|
|
|
|
|
|
|
|
for name in rating_modules:
|
|
|
|
|
|
|
|
rater = rating_modules[name].Rater(results)
|
|
|
|
output[name] = rater.rate()
|
|
|
|
|
|
|
|
return output
|