19
19
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
20
# SOFTWARE.
21
21
22
- from typing import Iterator , Tuple , Optional , Dict , Any
22
+ from typing import Iterator , Tuple , Optional , Dict , Any , Union , Container
23
23
24
24
import xarray as xr
25
25
import zarr
@@ -340,7 +340,13 @@ def get_type_specifiers_for_data(self, data_id: str) -> Tuple[str, ...]:
340
340
self ._get_dataset_and_collection_metadata (data_id )
341
341
return self .get_type_specifiers ()
342
342
343
- def get_data_ids (self , type_specifier : str = None , include_titles = True ) -> Iterator [Tuple [str , Optional [str ]]]:
343
+ def get_data_ids (self ,
344
+ type_specifier : str = None ,
345
+ include_attrs : Container [str ] = None ) -> \
346
+ Union [Iterator [str ], Iterator [Tuple [str , Dict [str , Any ]]]]:
347
+ return_tuples = include_attrs is not None
348
+ # TODO: respect names other than "title" in include_attrs
349
+ include_titles = return_tuples and 'title' in include_attrs
344
350
if self ._is_supported_type_specifier (type_specifier ):
345
351
if self ._sentinel_hub is not None :
346
352
metadata = SentinelHubMetadata ()
@@ -356,11 +362,23 @@ def get_data_ids(self, type_specifier: str = None, include_titles=True) -> Itera
356
362
if collection_dataset is not None :
357
363
dataset_name = collection_dataset .get ('dataset_name' )
358
364
if dataset_name is not None :
359
- yield dataset_name , collection_title
365
+ if return_tuples :
366
+ if include_titles :
367
+ yield dataset_name , {'title' : collection_title }
368
+ else :
369
+ yield dataset_name , {}
370
+ else :
371
+ yield dataset_name
360
372
else :
361
373
datasets = SentinelHubMetadata ().datasets
362
374
for dataset_name , dataset_metadata in datasets .items ():
363
- yield dataset_name , dataset_metadata .get ('title' ) if include_titles else None
375
+ if return_tuples :
376
+ if include_titles :
377
+ yield dataset_name , {'title' : dataset_metadata .get ('title' )}
378
+ else :
379
+ yield dataset_name , {}
380
+ else :
381
+ yield dataset_name
364
382
365
383
def has_data (self , data_id : str , type_specifier : str = None ) -> bool :
366
384
if self ._is_supported_type_specifier (type_specifier ):
0 commit comments