From 6ea0c63f57caccc154f011bc8d79f161b13b109e Mon Sep 17 00:00:00 2001 From: Tom Kralidis Date: Mon, 15 Jan 2024 22:44:23 +0000 Subject: [PATCH] distribution: ensure format_version exists or emit gco:nilReason=missing --- docs/content/reference/formats/iso19139-hnap.md | 8 ++++---- pygeometa/schemas/iso19139/main.j2 | 10 ++++++++-- pygeometa/schemas/iso19139_2/main.j2 | 10 ++++++++-- pygeometa/schemas/iso19139_hnap/main.j2 | 6 +++++- pygeometa/schemas/wmo_cmp/main.j2 | 10 ++++++++-- tests/run_tests.py | 12 +++++++++--- 6 files changed, 42 insertions(+), 14 deletions(-) diff --git a/docs/content/reference/formats/iso19139-hnap.md b/docs/content/reference/formats/iso19139-hnap.md index 33bd2a5..dcba4fe 100644 --- a/docs/content/reference/formats/iso19139-hnap.md +++ b/docs/content/reference/formats/iso19139-hnap.md @@ -47,7 +47,7 @@ distribution: format: en: Other fr: Autre - format_version: 0 + format_version: '0' function: download waf_eng-CAN: @@ -62,7 +62,7 @@ distribution: format: en: Other fr: Autre - format_version: 0 + format_version: '0' function: download wms_eng-CAN: @@ -72,7 +72,7 @@ distribution: fr: Service Web type: OGC:WMS format: WMS - format_version: 1.1.1 + format_version: '1.1.1' name: en: GDPS.ETA_TT fr: GDPS.ETA_TT @@ -85,7 +85,7 @@ distribution: fr: Service Web type: OGC:WMS format: WMS - format_version: 1.1.1 + format_version: '1.1.1' name: en: GDPS.ETA_TT fr: GDPS.ETA_TT diff --git a/pygeometa/schemas/iso19139/main.j2 b/pygeometa/schemas/iso19139/main.j2 index 069c3f0..55704cb 100644 --- a/pygeometa/schemas/iso19139/main.j2 +++ b/pygeometa/schemas/iso19139/main.j2 @@ -384,11 +384,17 @@ {% for k, v in record['distribution'].items() %} - {% if v['format'] and v['format_version'] %} + {% if v['format'] %} {{ v['format'] }} - {{ v['format_version'] }} + {% if v['format_version'] %} + + {{ v['format_version'] }} + + {% else %} + + {% endif %} {% endif %} diff --git a/pygeometa/schemas/iso19139_2/main.j2 b/pygeometa/schemas/iso19139_2/main.j2 index 20f3152..eb773e3 100644 --- a/pygeometa/schemas/iso19139_2/main.j2 +++ b/pygeometa/schemas/iso19139_2/main.j2 @@ -384,11 +384,17 @@ {% for k, v in record['distribution'].items() %} - {% if v['format'] and v['format_version'] %} + {% if v['format'] %} {{ v['format'] }} - {{ v['format_version'] }} + {% if v['format_version'] %} + + {{ v['format_version'] }} + + {% else %} + + {% endif %} {% endif %} diff --git a/pygeometa/schemas/iso19139_hnap/main.j2 b/pygeometa/schemas/iso19139_hnap/main.j2 index f25c965..3d2364f 100644 --- a/pygeometa/schemas/iso19139_hnap/main.j2 +++ b/pygeometa/schemas/iso19139_hnap/main.j2 @@ -541,13 +541,17 @@ {% set formats = prune_distribution_formats(record['distribution']) %} {% for v in formats %} - {% if v['format_en'] and v['format_fr'] and v['format_version'] %} + {% if v['format_en'] and v['format_fr'] %} {{ cs.get_freetext('name', 'fra', get_charstring(v.get('format'), 'en', 'fr')) }} + {% if v['format_version'] %} {{ v['format_version'] }} + {% else %} + + {% endif %} {% endif %} diff --git a/pygeometa/schemas/wmo_cmp/main.j2 b/pygeometa/schemas/wmo_cmp/main.j2 index 5d64c30..464cb69 100644 --- a/pygeometa/schemas/wmo_cmp/main.j2 +++ b/pygeometa/schemas/wmo_cmp/main.j2 @@ -364,11 +364,17 @@ {% for k, v in record['distribution'].items() %} - {% if v['format'] and v['format_version'] %} + {% if v['format'] %} {{ v['format'] }} - {{ v['format_version'] }} + {% if v['format_version'] %} + + {{ v['format_version'] }} + + {% else %} + + {% endif %} {% endif %} diff --git a/tests/run_tests.py b/tests/run_tests.py index d81865a..7234e2c 100644 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -178,13 +178,19 @@ def test_prune_distribution_formats(self): formats = { 'wms': { - 'format_en': 'image', 'format_fr': 'image', 'format_version': 2 + 'format_en': 'image', + 'format_fr': 'image', + 'format_version': '2' }, 'wfs': { - 'format_en': 'GRIB2', 'format_fr': 'GRIB2', 'format_version': 2 + 'format_en': 'GRIB2', + 'format_fr': 'GRIB2', + 'format_version': '2' }, 'wcs': { - 'format_en': 'GRIB2', 'format_fr': 'GRIB2', 'format_version': 2 + 'format_en': 'GRIB2', + 'format_fr': 'GRIB2', + 'format_version': '2' } }