416 def __getitem__(self, key):
417 try:
418 start = key.start
419 stop = key.stop
420 except AttributeError:
421 try:
422 assert 0 <= key < self.bytelength
423 return ord(self.filemap[key + self.byteoffset])
424 except TypeError:
425
426 return self.filemap[key + self.byteoffset]
427 else:
428 if start is None:
429 start = 0
430 if stop is None:
431 stop = self.bytelength
432 assert key.step is None
433 assert 0 <= start < self.bytelength
434 assert 0 <= stop <= self.bytelength
435 s = slice(start + self.byteoffset, stop + self.byteoffset)
436 return bytearray(self.filemap.__getitem__(s))
437