Skip to content

Commit

Permalink
allow multiple hrefs, take first
Browse files Browse the repository at this point in the history
  • Loading branch information
konstntokas committed Dec 6, 2024
1 parent b397ae8 commit 30df215
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions xcube_stac/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,12 @@ def parse_item(self, item: pystac.Item, **open_params) -> pystac.Item:
f"{href_base}/**/*_{asset_name}_{res_select}m.jp2"
)
if len(hrefs) == 0:
raise DataStoreError(
LOG.warning(
"No jp2 file found for "
f"{href_base}/**/*_{asset_name}_{res_select}m.jp2"
)
elif len(hrefs) > 1:
hrefs = self._fs.glob(f"{href_base}/**/*_{asset_name}_*.jp2")
if len(hrefs) > 1:
LOG.warning(
f"Multiple hrefs {hrefs} are found "
f"for {href_base}/**/*_{asset_name}_{res_select}m.jp2. "
Expand Down Expand Up @@ -381,11 +382,12 @@ def parse_item(self, item: pystac.Item, **open_params) -> pystac.Item:
f"{href_base}/**/*_{asset_name}_{res_select}m.jp2"
)
if len(hrefs) == 0:
raise DataStoreError(
LOG.warning(
"No jp2 file found for "
f"{href_base}/**/*_{asset_name}_{res_select}m.jp2"
)
elif len(hrefs) > 1:
hrefs = self._fs.glob(f"{href_base}/**/*_{asset_name}_*.jp2")
if len(hrefs) > 1:
LOG.warning(
f"Multiple hrefs {hrefs} are found "
f"for {href_base}/**/*_{asset_name}_{res_select}m.jp2. "
Expand Down

0 comments on commit 30df215

Please sign in to comment.