Skip to content

Commit

Permalink
add granule getter and setter (inside granules list)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhkennedy committed Dec 14, 2024
1 parent c6162ff commit dae6435
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions earthaccess/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,9 +937,9 @@ def doi(self, doi: str) -> Self:

return self

def load(self):
def load(self, count: int = -1):
# TODO - Handle paging (get all)
self.graunles = self.get()
self.granules = self.get(count)

@property
def granules(self) -> list:
Expand All @@ -960,6 +960,16 @@ def __iter__(self):
def __len__(self):
return len(self.granules)

def __getitem__(self, index: int):
# FIXME: allow slicing
# if isinstance(index, slice):
# return DataGranules(self.jobs[index])
return self.granules[index]

def __setitem__(self, index: int, granule: DataGranule):
self.granules[index] = granule
return self

# FIXME: Is a granule in this results object? what do we use to tell?
# def __contains__(self, job: Job):
# return job in self.jobs
Expand Down

0 comments on commit dae6435

Please sign in to comment.