Skip to content

Commit

Permalink
Merge pull request #406 from emmanuelmathot/fix404
Browse files Browse the repository at this point in the history
Fix get_bands in AssetEOExtension to return None if no eo:bands property for the asset
  • Loading branch information
Jon Duckworth authored Jun 7, 2021
2 parents d2cb2c9 + fcee6cd commit b2153c8
Show file tree
Hide file tree
Showing 4 changed files with 607 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### Fixed

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

### Removed

## [1.0.0-beta.3]
Expand Down
10 changes: 10 additions & 0 deletions pystac/extensions/eo.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,16 @@ class AssetEOExtension(EOExtension[pystac.Asset]):
"""If present, this will be a list containing 1 dictionary representing the
properties of the owning :class:`~pystac.Item`."""

def _get_bands(self) -> Optional[List[Band]]:
if BANDS_PROP not in self.properties:
return None
return list(
map(
lambda band: Band(band),
cast(List[Dict[str, Any]], self.properties.get(BANDS_PROP)),
)
)

def __init__(self, asset: pystac.Asset):
self.asset_href = asset.href
self.properties = asset.properties
Expand Down
Loading

0 comments on commit b2153c8

Please sign in to comment.