Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get_bands in AssetEOExtension to return None if no eo:bands property for the asset #406

Merged
merged 5 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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