Skip to content

Commit

Permalink
Revert "Remove parse"
Browse files Browse the repository at this point in the history
This reverts commit 7d3caf8.
  • Loading branch information
webb-ben committed Sep 14, 2024
1 parent 7d3caf8 commit d850f59
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pygeoapi_plugins/provider/sparql.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def _combine(self, properties, results):
for k, v in results.items():
# Join query results by key
values = [
item.get('value') if isinstance(item, dict) else item
self.parse(item.get('value') if isinstance(item, dict) else item)
for item in (v if isinstance(v, list) else [v])
]
# Return item or list of items
Expand Down Expand Up @@ -398,6 +398,23 @@ def delete(self, identifier):
def __repr__(self):
return f'<SPARQLProvider> {self.data}'

@staticmethod
def parse(value: str) -> list:
"""
Parse a string by splitting it on commas.
:param value: `str` to be parsed.
:returns: A `list` of strings if commas are present,
otherwise the original string.
"""
if '|' in value:
return value.split('|')
elif ', ' in value:
return value.split(', ')
else:
return value

@staticmethod
def combine_lists(dict_data: dict):
"""
Expand Down

0 comments on commit d850f59

Please sign in to comment.