diff --git a/CHANGES.md b/CHANGES.md index c79d8b4b..ea253ff6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,8 @@ # 7.2.0 (2024-11-05) -* Ensure compatibility between XarrayReader and other Readers by adding `**kwargs` on class methods +* Ensure compatibility between XarrayReader and other Readers by adding `**kwargs` on class methods (https://github.com/cogeotiff/rio-tiler/pull/762) + +* add `STACReader.get_asset_list()` method to enable easier customization of the asset listing/validation (https://github.com/cogeotiff/rio-tiler/pull/762) # 7.1.0 (2024-10-29) diff --git a/rio_tiler/io/stac.py b/rio_tiler/io/stac.py index 95b55b8c..00ef144c 100644 --- a/rio_tiler/io/stac.py +++ b/rio_tiler/io/stac.py @@ -3,7 +3,18 @@ import json import os import warnings -from typing import Any, Dict, Iterator, Optional, Sequence, Set, Tuple, Type, Union +from typing import ( + Any, + Dict, + Iterator, + List, + Optional, + Sequence, + Set, + Tuple, + Type, + Union, +) from urllib.parse import urlparse import attr @@ -273,7 +284,13 @@ def __attrs_post_init__(self): self.minzoom = self.minzoom if self.minzoom is not None else self._minzoom self.maxzoom = self.maxzoom if self.maxzoom is not None else self._maxzoom - self.assets = list( + self.assets = self.get_asset_list() + if not self.assets: + raise MissingAssets("No valid asset found. Asset's media types not supported") + + def get_asset_list(self) -> List[str]: + """Get valid asset list""" + return list( _get_assets( self.item, include=self.include_assets, @@ -282,8 +299,6 @@ def __attrs_post_init__(self): exclude_asset_types=self.exclude_asset_types, ) ) - if not self.assets: - raise MissingAssets("No valid asset found. Asset's media types not supported") def _get_reader(self, asset_info: AssetInfo) -> Tuple[Type[BaseReader], Dict]: """Get Asset Reader."""