'Returns a dictionary detailing information about the locations
of the indexed HDU within any associated file.  The values are
only valid after a read or write of the associated file with
no intervening changes to the `HDUList`.
Parameters
index : int
Index of HDU for which info is to be returned.
Returns
fileinfo : dict or None
The dictionary details information about the locations of
the indexed HDU within an associated file.  Returns `None`
when the HDU is not associated with a file.
Dictionary contents:
Key        Value
file       File object associated with the HDU
filename   Name of associated file object
filemode   Mode in which the file was opened (readonly,
update, append, denywrite, ostream)
resized    Flag that when `True` indicates that the data has been
resized since the last read/write so the returned values
may not be valid.
hdrLoc     Starting byte location of header in file
datLoc     Starting byte location of data block in file
datSpan    Data size including padding'

def fileinfo(self, index):

    if (self._file is not None):
        output = self[index].fileinfo()
        if (not output):
            f = None
            for hdu in self:
                info = hdu.fileinfo()
                if info:
                    f = info['file']
                    fm = info['filemode']
                    break
            output = {'file': f, 'filemode': fm, 'hdrLoc': None, 'datLoc': None, 'datSpan': None}
        output['filename'] = self._file.name
        output['resized'] = self._wasresized()
    else:
        output = None
    return output
