# retoor <retoor@molodetz.nl>
from __future__ import annotations

import logging

from devplacepy.services.jobs.isslop.analysis.domsignals.base import (
    DOM_CHECKS,
    DOM_SITE_CHECKS,
    DomPageContext,
    DomSiteContext,
)
from devplacepy.services.jobs.isslop.analysis.signals import Signal
from . import accessibility, builders, buildsignals, color, copy, layout, metaseo, typography

logger = logging.getLogger(__name__)


def run_dom_checks(page: DomPageContext) -> list[Signal]:
    findings: list[Signal] = []
    for func in DOM_CHECKS:
        try:
            findings.extend(func(page))
        except Exception as error:
            logger.warning("DOM check %s failed for %s: %s", func.__name__, page.url, error)
    return findings


def run_dom_site_checks(site: DomSiteContext) -> list[Signal]:
    findings: list[Signal] = []
    for func in DOM_SITE_CHECKS:
        try:
            findings.extend(func(site))
        except Exception as error:
            logger.warning("DOM site check %s failed: %s", func.__name__, error)
    return findings
