'The real update code.  If keyword already exists, its value and/or
comment will be updated.  Otherwise a new card will be appended.
This will not create a duplicate keyword except in the case of
commentary cards.  The only other way to force creation of a duplicate
is to use the insert(), append(), or extend() methods.'

def _update(self, card):

    (keyword, value, comment) = card
    keyword = keyword.upper()
    if keyword.startswith('HIERARCH    '):
        keyword = keyword[9:]
    if ((keyword not in Card._commentary_keywords) and (keyword in self._keyword_indices)):
        idx = self._keyword_indices[keyword][0]
        existing_card = self._cards[idx]
        existing_card.value = value
        if (comment is not None):
            existing_card.comment = comment
        if existing_card._modified:
            self._modified = True
    elif (keyword in Card._commentary_keywords):
        cards = self._splitcommentary(keyword, value)
        if (keyword in self._keyword_indices):
            idx = self.index(keyword, start=(len(self) - 1), stop=(-1))
            isblank = (not (keyword or value or comment))
            for c in reversed(cards):
                self.insert((idx + 1), c, useblanks=(not isblank))
        else:
            for c in cards:
                self.append(c, bottom=True)
    else:
        self.append(card)
