Skip to content

Commit

Permalink
safeguard OARec time
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis authored Jul 14, 2024
1 parent 91c70cf commit 1bb8587
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pygeometa/schemas/ogcapi_records/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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']:
Expand Down

0 comments on commit 1bb8587

Please sign in to comment.