def getFITSHduNames(fitsfile):
    """Return list of names to give HDUs given a FITS file."""
    nameset = set()
    names = []
    for i, hdu in enumerate(fitsfile):
        name = hdu.name
        if not name:
            name = 'hdu%i' % i
            while name in nameset:
                name += '~'
        else:
            name = name.lower()
            if 'EXTVER' in hdu.header:
                name = '%s%i' % (name, hdu.header['EXTVER'])
            if name in nameset:
                i = 2
                while name + str(i) in nameset:
                    i += 1
                name += str(i)
        nameset.add(name)
        names.append(name)
    return names
