'Returns an index into the ._cards list given a valid lookup key.'

def _cardindex(self, key):

    if isinstance(key, string_types):
        keyword = key
        n = 0
    elif isinstance(key, int):
        if (key < 0):
            key += len(self._cards)
        if ((key < 0) or (key >= len(self._cards))):
            raise IndexError('Header    index    out    of    range.')
        return key
    elif isinstance(key, slice):
        return key
    elif isinstance(key, tuple):
        if ((len(key) != 2) or (not isinstance(key[0], string_types)) or (not isinstance(key[1], int))):
            raise ValueError('Tuple    indices    must    be    2-tuples    consisting    of    a    keyword    string    and    an    integer    index.')
        (keyword, n) = key
    else:
        raise ValueError('Header    indices    must    be    either    a    string,    a    2-tuple,    or    an    integer.')
    keyword = Card.normalize_keyword(keyword)
    indices = self._keyword_indices.get(keyword, None)
    if (keyword and (not indices)):
        if ((len(keyword) > KEYWORD_LENGTH) or ('.' in keyword)):
            raise KeyError('Keyword    {!r}    not    found.'.format(keyword))
        else:
            indices = self._rvkc_indices.get(keyword, None)
    if (not indices):
        raise KeyError('Keyword    {!r}    not    found.'.format(keyword))
    try:
        return indices[n]
    except IndexError:
        raise IndexError('There    are    only    {}    {!r}    cards    in    the    header.'.format(len(indices), keyword))
