"""
GLAMWalk -- Volume 4: Libraries & Archives
13_sacred_texts_hard_gate.py

A hard public-domain gate for a genuinely mixed-license site: refuses the import outright if the page's own copyright meta tag is missing or ambiguous.

Source: Volume Four, Chapter 6 -- Sacred Texts Archive
Targets Python 3.11.4 -- see Volume One, Chapter 1.5/1.6.
"""

from bs4 import BeautifulSoup

def sacred_texts_pd_gate(html):
    """
    A hard gate, not a warning: refuse the import entirely if the
    page's own copyright meta tag is missing or doesn't explicitly
    say public domain. This site genuinely mixes PD and non-PD
    content on the same domain — there's no site-wide assumption
    that's safe to make.
    """
    soup = BeautifulSoup(html, "html.parser")
    meta = soup.find("meta", attrs={"name": "copyright"})
    if not meta:
        return False

    content = (meta.get("content") or "").lower()
    return "public domain" in content
