1 import gzip
2 import cPickle as serialize
3 from event import Event
4
6 '''
7 This class reads events from an i3odf file.
8 '''
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
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