fix: omettre temporalCoverage si date inconnue + TimeoutException explicite (#78)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Colin Maudry
2026-06-12 17:58:23 +02:00
parent cb93dbe05a
commit b8d73c7f7b
2 changed files with 11 additions and 2 deletions
+5 -1
View File
@@ -124,7 +124,11 @@ layout = [
"contentUrl": "https://www.data.gouv.fr/api/1/datasets/r/11cea8e8-df3e-4ed1-932b-781e2635e432", "contentUrl": "https://www.data.gouv.fr/api/1/datasets/r/11cea8e8-df3e-4ed1-932b-781e2635e432",
}, },
], ],
"temporalCoverage": f"2018-01-01/{update_date_iso[:10]}", **(
{"temporalCoverage": f"2018-01-01/{update_date_iso[:10]}"}
if update_date_iso
else {}
),
"spatialCoverage": { "spatialCoverage": {
"@type": "Place", "@type": "Place",
"address": {"countryCode": "FR"}, "address": {"countryCode": "FR"},
+6 -1
View File
@@ -80,7 +80,12 @@ def _fetch_remote_schema(url: str | None) -> dict | None:
return None return None
try: try:
raw = get(url, follow_redirects=True).raise_for_status().json() raw = get(url, follow_redirects=True).raise_for_status().json()
except (httpx.HTTPError, httpx.TransportError, json.JSONDecodeError) as e: except (
httpx.HTTPError,
httpx.TransportError,
httpx.TimeoutException,
json.JSONDecodeError,
) as e:
logger.error(f"Schéma distant indisponible ({url}) : {e}") logger.error(f"Schéma distant indisponible ({url}) : {e}")
return None return None
return _validate_schema(raw) return _validate_schema(raw)