Skip to content

Commit

Permalink
Revert "Remove parse" (#24)
Browse files Browse the repository at this point in the history
* Revert "Remove parse"

This reverts commit 7d3caf8.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
webb-ben and pre-commit-ci[bot] authored Sep 14, 2024
1 parent 0f226bf commit d87a9ea
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 d87a9ea

Please sign in to comment.