'Make sure that if the primary header needs the keyword ``EXTEND`` that
it has it and it is correct.'

def update_extend(self):

    if (not len(self)):
        return
    if (not isinstance(self[0], PrimaryHDU)):
        return
    hdr = self[0].header
    def get_first_ext():
        try:
            return self[1]
        except IndexError:
            return None
    if ('EXTEND' in hdr):
        if ((not hdr['EXTEND']) and (get_first_ext() is not None)):
            hdr['EXTEND'] = True
    elif (get_first_ext() is not None):
        if (hdr['NAXIS'] == 0):
            hdr.set('EXTEND', True, after='NAXIS')
        else:
            n = hdr['NAXIS']
            hdr.set('EXTEND', True, after=('NAXIS' + str(n)))
