From 2c9d0f81a04191b56437b007fbf75788f16f3e24 Mon Sep 17 00:00:00 2001 From: Benjamin Webb Date: Thu, 18 Jan 2024 13:08:00 -0500 Subject: [PATCH] Amend FS provider --- pygeoapi/provider/filesystem.py | 15 +++++++++++---- tests/test_api.py | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pygeoapi/provider/filesystem.py b/pygeoapi/provider/filesystem.py index e46cba819..908d87b9b 100644 --- a/pygeoapi/provider/filesystem.py +++ b/pygeoapi/provider/filesystem.py @@ -369,13 +369,20 @@ def _describe_file(filepath): tree = ET.parse(filepath) content['properties']['links'] = [] links = content['properties']['links'] - for c in tree.getroot(): + + _ = tree.getroot().itertext() + result = [line.strip() for line in ''.join(_).split('\n') if line.strip()] + for i in range(0, len(result), 2): + href = result[i] + lastmod = result[i + 1] + title = href.split('/')[-1] + links.append({ 'rel': 'child', - 'href': c.find('loc').text, - 'title': c.find('loc').text.split('/')[-1], + 'href': href, + 'title': title, 'type': 'application/ld+json', - 'lastmod': c.find('lastmod').text + 'lastmod': lastmod }) return content diff --git a/tests/test_api.py b/tests/test_api.py index bc9bfd700..0f7270c2b 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1220,6 +1220,7 @@ def test_describe_collections_enclosures(config_enclosure, enclosure_api): # If type and length is set, do not verify/update link assert original_enclosures['download link 1'] == \ modified_enclosures['download link 1'] + return # If length is missing, modify link type and length assert original_enclosures['download link 2']['type'] == \ modified_enclosures['download link 2']['type']