Package python :: Module reader
[hide private]
[frames] | no frames]

Source Code for Module python.reader

 1  import gzip 
 2  import cPickle as serialize 
 3  from event import Event 
 4   
5 -class EventReader:
6 ''' 7 This class reads events from an i3odf file. 8 '''
9 - def __init__(self, filename):
10 ''' 11 The constructor takes a filename and opens the file. 12 ''' 13 if filename.endswith(".gz") : 14 self.file = gzip.open(filename,"rb") 15 else: 16 self.file = open(filename,"rb")
17
18 - def GetEvent(self):
19 ''' 20 Returns an event from the file. "None" is returned for EOF. 21 ''' 22 try: 23 return serialize.load(self.file) 24 except EOFError: 25 return None
26