Skip to content

Commit b2153c8

Browse files
author
Jon Duckworth
authored
Merge pull request #406 from emmanuelmathot/fix404
Fix get_bands in AssetEOExtension to return None if no eo:bands property for the asset
2 parents d2cb2c9 + fcee6cd commit b2153c8

File tree

4 files changed

+607
-0
lines changed

4 files changed

+607
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
### Fixed
1010

11+
- Fixed returned None by `EOExtension.get_bands` for asset without EO bands ([#406](https://github.com/stac-utils/pystac/pull/406))
12+
1113
### Removed
1214

1315
## [1.0.0-beta.3]

pystac/extensions/eo.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,16 @@ class AssetEOExtension(EOExtension[pystac.Asset]):
437437
"""If present, this will be a list containing 1 dictionary representing the
438438
properties of the owning :class:`~pystac.Item`."""
439439

440+
def _get_bands(self) -> Optional[List[Band]]:
441+
if BANDS_PROP not in self.properties:
442+
return None
443+
return list(
444+
map(
445+
lambda band: Band(band),
446+
cast(List[Dict[str, Any]], self.properties.get(BANDS_PROP)),
447+
)
448+
)
449+
440450
def __init__(self, asset: pystac.Asset):
441451
self.asset_href = asset.href
442452
self.properties = asset.properties

0 commit comments

Comments
 (0)