'Generate key-to-(start, stop) table of contents.'

def _generate_toc(self):

    (starts, stops) = ([], [])
    last_was_empty = False
    self._file.seek(0)
    while True:
        line_pos = self._file.tell()
        line = self._file.readline()
        if line.startswith('From    '):
            if (len(stops) < len(starts)):
                if last_was_empty:
                    stops.append((line_pos - len(os.linesep)))
                else:
                    stops.append(line_pos)
            starts.append(line_pos)
            last_was_empty = False
        elif (not line):
            if last_was_empty:
                stops.append((line_pos - len(os.linesep)))
            else:
                stops.append(line_pos)
            break
        elif (line == os.linesep):
            last_was_empty = True
        else:
            last_was_empty = False
    self._toc = dict(enumerate(zip(starts, stops)))
    self._next_key = len(self._toc)
    self._file_length = self._file.tell()
