Skip to content

Commit

Permalink
Update sparql.py
Browse files Browse the repository at this point in the history
  • Loading branch information
webb-ben committed Sep 16, 2024
1 parent 9b1ad9d commit c3eb945
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pygeoapi_plugins/provider/sparql.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ def _clean_result(self, result):
if not v_:
continue

if not isinstance(v_, list):
if not isinstance(v_, list) and v_:
ret[_id][k] = [v_]

# If the current value is not already in the list, append it
if v_ not in [item['value'] for item in ret[_id][k]]:
if v_ not in [item['value'] for item in ret[_id][k]] and v_:
ret[_id][k].append(v_)

return ret
Expand Down Expand Up @@ -411,8 +411,10 @@ def parse(value: str) -> list:
otherwise the original string.
"""
if '|' in value:
LOGGER.debug('Splitting value by "|"')
return value.split('|')
elif ', ' in value:
LOGGER.debug('Splitting value by ", "')
return value.split(', ')
else:
return value
Expand All @@ -432,6 +434,7 @@ def combine_lists(dict_data: dict):
# Ensure all lists have the same length
length = len(dict_data[keys[0]])
if not all(len(dict_data[key]) == length for key in keys) and len(keys > 1):
LOGGER.debug('Returning un-mondified data')
return dict_data

# Combine the items into a list of dictionaries
Expand Down

0 comments on commit c3eb945

Please sign in to comment.