@@ -443,27 +443,34 @@ def get_collections(self) -> Iterator[Collection]:
443
443
call_modifier (self .modifier , collection )
444
444
yield collection
445
445
446
- def get_items (
447
- self , * ids : str , recursive : bool | None = None
448
- ) -> Iterator ["Item_Type" ]:
446
+ def get_items (self , * ids : str , recursive : bool = True ) -> Iterator ["Item_Type" ]:
449
447
"""Return all items of this catalog.
450
448
451
449
Args:
452
450
ids: Zero or more item ids to find.
453
- recursive: unused in pystac-client, but needed for falling back to pystac
451
+ recursive : If True, search this catalog and all children for the
452
+ item; otherwise, only search the items of this catalog. Defaults
453
+ to True.
454
454
455
455
Return:
456
456
Iterator[Item]: Iterator of items whose parent is this
457
457
catalog.
458
458
"""
459
459
if self .conforms_to (ConformanceClasses .ITEM_SEARCH ):
460
- search = self .search (ids = ids )
460
+ if recursive :
461
+ search = self .search (ids = ids )
462
+ try :
463
+ yield from search .items ()
464
+ return
465
+ except APIError :
466
+ child_catalogs = [catalog for catalog , _ , _ in self .walk ()]
467
+ search = self .search (ids = ids , collections = [self , * child_catalogs ])
468
+ else :
469
+ search = self .search (ids = ids , collections = [self .id ])
461
470
yield from search .items ()
462
471
else :
463
472
self ._warn_about_fallback ("ITEM_SEARCH" )
464
- for item in super ().get_items (
465
- * ids , recursive = recursive is None or recursive
466
- ):
473
+ for item in super ().get_items (* ids , recursive = recursive ):
467
474
call_modifier (self .modifier , item )
468
475
yield item
469
476
0 commit comments