'Internal: parse a message number (or cur, first, etc.).'

def _parseindex(self, seq, all):

    if isnumeric(seq):
        try:
            return int(seq)
        except (OverflowError, ValueError):
            return sys.maxint
    if (seq in ('cur', '.')):
        return self.getcurrent()
    if (seq == 'first'):
        return all[0]
    if (seq == 'last'):
        return all[(-1)]
    if (seq == 'next'):
        n = self.getcurrent()
        i = bisect(all, n)
        try:
            return all[i]
        except IndexError:
            raise Error, 'no    next    message'
    if (seq == 'prev'):
        n = self.getcurrent()
        i = bisect(all, (n - 1))
        if (i == 0):
            raise Error, 'no    prev    message'
        try:
            return all[(i - 1)]
        except IndexError:
            raise Error, 'no    prev    message'
    raise Error, None
