From 1bb85879faa803b2d68411d4b3af3beab5ac1bc5 Mon Sep 17 00:00:00 2001 From: Tom Kralidis Date: Sun, 14 Jul 2024 10:13:03 -0400 Subject: [PATCH] safeguard OARec time --- pygeometa/schemas/ogcapi_records/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pygeometa/schemas/ogcapi_records/__init__.py b/pygeometa/schemas/ogcapi_records/__init__.py index bbfe57e..ae89910 100644 --- a/pygeometa/schemas/ogcapi_records/__init__.py +++ b/pygeometa/schemas/ogcapi_records/__init__.py @@ -125,9 +125,7 @@ def write(self, mcf: dict, stringify: str = True) -> Union[dict, str]: } LOGGER.debug('Checking for temporal') - if all(['temporal' in mcf['identification']['extents'], - mcf['identification']['extents']['temporal'] != [{}]]): - + try: begin = mcf['identification']['extents']['temporal'][0]['begin'] end = mcf['identification']['extents']['temporal'][0].get('end') @@ -151,6 +149,9 @@ def write(self, mcf: dict, stringify: str = True) -> Union[dict, str]: if 'resolution' in mcf['identification']['extents']['temporal'][0]: # noqa record['time']['resolution'] = mcf['identification']['extents']['temporal'][0]['resolution'] # noqa + except (IndexError, KeyError): + record['time'] = None + LOGGER.debug('Checking for dates') if 'dates' in mcf['identification']: if 'creation' in mcf['identification']['dates']: