Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

fix: reject standalone Commons PD-US text helpers (fixes #235) (#236)

agamrafaeli-instincteb6436492810
diff --git a/scripts/oss/commons_licences.py b/scripts/oss/commons_licences.py
index 28a67199b..04bc1aaa0 100644
--- a/scripts/oss/commons_licences.py
+++ b/scripts/oss/commons_licences.py
@@ -19,15 +19,23 @@ from urllib.parse import unquote, urlparse
ROOT = Path(__file__).resolve().parents[2]
UA = {"User-Agent": "statecraft-israel-licence-audit/1.0 (https://github.com/eyalgolan/statecraft-israel)"}
-US_STATUS = ("PD-US", "Cc-zero")
# Only the {{PD-1996}} licence tag itself. {{PD-1996-text}} is a text helper that other tags also transclude,
# including PD-India-URAA, PD-Poland and PD-HU-unknown, so on its own it is not an explicit US status.
US_1996_TEMPLATES = {"PD-1996"}
+# The dated composite tags on the Weizmann source explicitly include US expiry.
+US_EXPIRED_COMPOSITES = {"PD-old-70-expired", "PD-old-70-1923"}
# Portrait files with no people.yaml record (promo/CREDITS.md lists Dayan as CC0).
EXTRA = [("promo/ref/people/Moshe_Dayan_1962_CC0.jpg",
"https://commons.wikimedia.org/wiki/File:Moshe_Dayan_met_mgr._A.C._Ramselaar_(cropped).jpg")]
+def _has_us_status(name: str) -> bool:
+ # Shared text/localisation helpers are not licence tags in their own right.
+ if "/" in name or re.search(r"-text(?:$|-)", name):
+ return False
+ return name.startswith("PD-US") or name == "Cc-zero" or name in US_1996_TEMPLATES or name in US_EXPIRED_COMPOSITES
+
+
def rule_for(path: str, source: str, licence_short: str, templates: list[str], artist: str) -> dict:
names = [t.removeprefix("Template:") for t in templates]
low = licence_short.lower()
@@ -40,7 +48,7 @@ def rule_for(path: str, source: str, licence_short: str, templates: list[str], a
rule.update(status="owner-verify", note=f"Commons licence '{licence_short}' is not public domain or CC0")
elif any(n == "Not-PD-US-URAA" or n.startswith("Not-PD-US-URAA/") for n in names):
rule.update(status="owner-verify", note="Commons explicitly warns Not-PD-US-URAA: US copyright restored")
- elif not any(n.startswith(US_STATUS) or n in US_1996_TEMPLATES for n in names):
+ elif not any(_has_us_status(n) for n in names):
rule.update(status="owner-verify", note="no explicit US status template on the Commons page")
return rule
diff --git a/scripts/oss/tests/test_commons_licences.py b/scripts/oss/tests/test_commons_licences.py
index 71efbe2d3..8c3c81d6d 100644
--- a/scripts/oss/tests/test_commons_licences.py
+++ b/scripts/oss/tests/test_commons_licences.py
@@ -65,3 +65,27 @@ def test_pd_1996_text_helper_alone_is_not_us_status():
# {{PD-India-URAA}} (and PD-Poland, PD-HU-unknown and others) transclude {{PD-1996-text}} without {{PD-1996}}.
r = cl.rule_for("p/a.jpg", "s", "Public domain", ["Template:PD-India-URAA", "Template:PD-1996-text"], "")
assert r["status"] == "owner-verify"
+
+
+def test_us_text_helpers_are_not_status_tags():
+ for helper in ("PD-US-expired-text", "PD-US-expired-text/en", "PD-US-no-notice-text"):
+ r = cl.rule_for("p/a.jpg", "s", "Public domain", ["Template:PD-Israel", "Template:" + helper], "")
+ assert r["status"] == "owner-verify", helper
+
+
+def test_weizmann_expired_composite_tag_is_independent_us_status():
+ for tag in ("PD-old-70-expired", "PD-old-70-1923"):
+ r = cl.rule_for("p/a.jpg", "s", "Public domain", ["Template:" + tag, "Template:PD-US-expired-text"], "")
+ assert r["status"] == "verified", tag
+ assert cl.rule_for("p/a.jpg", "s", "Public domain", ["Template:" + tag], "")["status"] == "verified"
+
+
+def test_plain_old_tag_and_composite_helpers_are_not_us_status():
+ for tag in ("PD-old-70", "PD-old-text", "PD-old-70-expired/en", "PD-old-X-expired"):
+ r = cl.rule_for("p/a.jpg", "s", "Public domain", ["Template:" + tag], "")
+ assert r["status"] == "owner-verify", tag
+
+
+def test_primary_us_tags_still_verify():
+ for tag in ("PD-US-expired", "PD-USGov", "PD-USGov-NARA", "PD-US-no notice"):
+ assert cl.rule_for("p/a.jpg", "s", "Public domain", ["Template:" + tag], "")["status"] == "verified"