Skip to content

Commit

Permalink
aggregate bare keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Sep 22, 2023
1 parent f59224c commit 22cab2d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pygeometa/schemas/ogcapi_records/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ def write(self, mcf: dict, stringify: str = True) -> Union[dict, str]:
record['properties']['contacts'] = self.generate_contacts(
mcf['contact'])

all_keywords = []

LOGGER.debug('Checking for keywords')
for key, value in mcf['identification']['keywords'].items():
theme = {'concepts': []}
Expand All @@ -198,17 +200,21 @@ def write(self, mcf: dict, stringify: str = True) -> Union[dict, str]:
scheme = value['vocabulary']['name']

if scheme is None:
record['properties']['keywords'] = keywords[0]
continue

LOGGER.debug('Keywords found without vocabulary')
LOGGER.debug('Aggregating as bare keywords')
all_keywords.extend(keywords[0])
else:
LOGGER.debug('Adding as theme/concepts')
for kw in keywords[0]:
theme['concepts'].append({'id': kw})

theme['scheme'] = scheme

record['properties']['themes'].append(theme)

if all_keywords:
record['properties']['keywords'] = all_keywords

LOGGER.debug('Checking for licensing')
if mcf['identification'].get('license') is not None:
license = mcf['identification']['license']
Expand Down

0 comments on commit 22cab2d

Please sign in to comment.