Skip to content

Commit

Permalink
fix downloading by common_name
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhanson committed Jun 12, 2020
1 parent 79593de commit c2fbcd0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions satstac/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ def assets_by_common_name(self):
if self._assets_by_common_name is None:
self._assets_by_common_name = {}
for a in self.assets:
bands = self.assets[a].get('eo:bands', [])
bands = []
col = self.collection()._data
if 'eo:bands' in self.assets[a]:
bands = self.assets[a]['eo:bands']
elif 'item_assets' in col:
bands = col['item_assets'][a].get('eo:bands', [])
if len(bands) == 1:
eo_band = bands[0].get('common_name')
if eo_band:
Expand All @@ -87,7 +92,7 @@ def assets_by_common_name(self):

def asset(self, key):
""" Get asset for this key OR common_name """
if key in self.assets:
if key in self.assets.keys():
return self.assets[key]
elif key in self.assets_by_common_name:
return self.assets_by_common_name[key]
Expand Down

0 comments on commit c2fbcd0

Please sign in to comment.