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.

tools: only {{PD-1996}} itself counts as an explicit US status (refs #30) (#223)

agamrafaeli-instinct470881285a62
diff --git a/scripts/oss/commons_licences.py b/scripts/oss/commons_licences.py
index deefb63b5..28a67199b 100644
--- a/scripts/oss/commons_licences.py
+++ b/scripts/oss/commons_licences.py
@@ -19,7 +19,10 @@ 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", "PD-1996", "Cc-zero")
+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"}
# 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")]
@@ -35,7 +38,9 @@ def rule_for(path: str, source: str, licence_short: str, templates: list[str], a
"artist": re.sub(r"<[^>]+>", "", html.unescape(artist)).strip()}
if licence == "unknown":
rule.update(status="owner-verify", note=f"Commons licence '{licence_short}' is not public domain or CC0")
- elif not any(n.startswith(US_STATUS) for n in names):
+ 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):
rule.update(status="owner-verify", note="no explicit US status template on the Commons page")
return rule
@@ -47,7 +52,7 @@ def _commons(title: str, session) -> tuple[str, list[str], str]:
page = next(iter(j["query"]["pages"].values()))
meta = (page.get("imageinfo") or [{}])[0].get("extmetadata", {})
templates = [t["title"] for t in page.get("templates", [])
- if re.match(r"Template:(PD-|Cc-zero|Cc-by)", t["title"], re.I)]
+ if re.match(r"Template:(PD-|Not-PD-US-URAA(?:/|$)|Cc-zero|Cc-by)", t["title"], re.I)]
return meta.get("LicenseShortName", {}).get("value", "UNKNOWN"), templates, meta.get("Artist", {}).get("value", "")
diff --git a/scripts/oss/tests/test_commons_licences.py b/scripts/oss/tests/test_commons_licences.py
index 9a2a85f74..71efbe2d3 100644
--- a/scripts/oss/tests/test_commons_licences.py
+++ b/scripts/oss/tests/test_commons_licences.py
@@ -22,3 +22,46 @@ def test_share_alike_is_recorded_as_unknown_licence():
r = cl.rule_for("p/a.jpg", "s", "CC BY-SA 4.0", ["Template:Cc-by-sa-4.0"], "")
assert r["licence"] == "unknown" and r["status"] == "owner-verify"
assert "not public domain or CC0" in r["note"]
+
+
+def test_explicit_us_restoration_warning_cannot_be_verified_by_nested_pd_text():
+ r = cl.rule_for("p/a.jpg", "s", "Public domain",
+ ["Template:PD-Israel", "Template:PD-US-expired", "Template:Not-PD-US-URAA",
+ "Template:PD-1996-text/country", "Template:PD-1996-text/date"], "")
+ assert r["status"] == "owner-verify"
+ assert "Not-PD-US-URAA" in r["note"]
+
+
+def test_commons_keeps_the_us_restoration_warning_from_the_api():
+ class Response:
+ def json(self):
+ return {"query": {"pages": {"1": {
+ "imageinfo": [{"extmetadata": {"LicenseShortName": {"value": "Public domain"}}}],
+ "templates": [{"title": name} for name in
+ ["Template:PD-Israel", "Template:Not-PD-US-URAA",
+ "Template:PD-1996-text/date"]]}}}}
+
+ class Session:
+ def get(self, *args, **kwargs):
+ return Response()
+
+ short, templates, artist = cl._commons("File:A.jpg", Session())
+ assert "Template:Not-PD-US-URAA" in templates
+ assert cl.rule_for("p/a.jpg", "s", short, templates, artist)["status"] == "owner-verify"
+
+
+def test_pd_1996_parameter_subtemplates_are_not_us_status_on_their_own():
+ r = cl.rule_for("p/a.jpg", "s", "Public domain",
+ ["Template:PD-Israel", "Template:PD-1996-text/country", "Template:PD-1996-text/date"], "")
+ assert r["status"] == "owner-verify"
+
+
+def test_actual_pd_1996_template_remains_verified():
+ r = cl.rule_for("p/a.jpg", "s", "Public domain", ["Template:PD-1996", "Template:PD-1996-text"], "")
+ assert r["status"] == "verified"
+
+
+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"