INNER CODE UNIT · Python

attempt

zachlagden/Pi-hole-Optimized-Blocklists · .github/triage/triage/__main__.py:28

def attempt(evidence: Evidence, label: str, action: Callable[[], T], default: T) -> T:
    try:
        return action()
    except Exception as error:
        evidence.failures.append(f"{label}: {type(error).__name__}: {error}")
        print(f"::warning::{label} failed: {type(error).__name__}: {error}", file=sys.stderr)
        return default


def gather_repo_and_sources(evidence: Evidence, repo_root: Path) -> None:
    domain, apex = evidence.domain, evidence.apex
    evidence.custom = custom_matches(repo_root, domain)
    evidence.whitelist = whitelist_matches(repo_root, domain)
    targets = set(self_and_parents(domain)) | {apex}
    sources = load_sources(repo_root)
    evidence.sources = attempt(evidence, "source scan", lambda: scan_sources(sources, targets), [])
    evidence.coverage = build_coverage(domain, evidence.sources, evidence.custom, evidence.whitelist)
    if apex != domain:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…