Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

Commit

Permalink
remove ugly generator function
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Neise committed Feb 12, 2018
1 parent 65cd455 commit a588a32
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions protozfitsreader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,17 @@ def __init__(self, fname):
rawzfitsreader.open(self.fname + ":Events")
self.numrows = rawzfitsreader.getNumRows()
self.run_id = 0
self.generator = self.__generator()

def __generator(self):
for _ in range(self.numrows):
event = L0_pb2.CameraEvent()
event.ParseFromString(rawzfitsreader.readEvent())
yield Event(event, self.run_id)

def __iter__(self):
return self.generator
return self

def __next__(self):
event = L0_pb2.CameraEvent()
try:
event.ParseFromString(rawzfitsreader.readEvent())
return Event(event, self.run_id)
except EOFError:
raise StopIteration

def list_tables(self):
return rawzfitsreader.listAllTables(self.fname)
Expand Down

0 comments on commit a588a32

Please sign in to comment.