210 def __next__(self):
211 """
212 Iterate to next key
213 """
214
215 pos = self.rootfile.tell()
216 large = pos > 0x80000000
217 nbytes = int.from_bytes(self.rootfile.read(4), byteorder)
218 if (nbytes == 0):
219 raise StopIteration()
220 self.rootfile.seek(-4, 1)
221 result = self.Key(self.rootfile.read(nbytes), large)
222 if pos == self.seekfree:
223 result.showname = b'FreeSegments'
224 elif pos == self.seekinfo:
225 result.showname = b'StreamerInfo'
226 elif pos == self.seekkeys:
227 result.showname = b'KeysList'
228
229 if result.showname == b'TFile':
230 result.filename, pos = result.get_string(result.data, 0)
231 result.filetitle, pos = result.get_string(result.data, pos)
232 result.version = int.from_bytes(result.data[pos:pos+2], byteorder)
233 result.nbyteskeys = int.from_bytes(result.data[pos+10:pos+14], byteorder)
234 result.nbytesname = int.from_bytes(result.data[pos+14:pos+18], byteorder)
235 if result.version > 1000:
236 result.seekdir = int.from_bytes(result.data[pos+18:pos+26], byteorder)
237 result.seekparent = int.from_bytes(result.data[pos+26:pos+34], byteorder)
238 self.seekkeys = int.from_bytes(result.data[pos+34:pos+42], byteorder)
239 else:
240 result.seekdir = int.from_bytes(result.data[pos+18:pos+22], byteorder)
241 result.seekparent = int.from_bytes(result.data[pos+22:pos+26], byteorder)
242 self.seekkeys = int.from_bytes(result.data[pos+26:pos+30], byteorder)
243 return result
244
245