'Returns the FITS file header(s) in a readable format.
Parameters
extensions : list of int or str, optional
Format only specific HDU(s), identified by number or name.
The name can be composed of the "EXTNAME" or "EXTNAME,EXTVER"
keywords.
keywords : list of str, optional
Keywords for which the value(s) should be returned.
If not specified, then the entire header is returned.
compressed : boolean, optional
If True, shows the header describing the compression, rather than
the header obtained after decompression. (Affects FITS files
containing `CompImageHDU` extensions only.)
Returns
formatted_header : str or astropy.table.Table
Traditional 80-char wide format in the case of `HeaderFormatter`;
an Astropy Table object in the case of `TableHeaderFormatter`.'

def parse(self, extensions=None, keywords=None, compressed=False):

    if (extensions is None):
        hdukeys = range(len(self._hdulist))
    else:
        hdukeys = []
        for ext in extensions:
            try:
                hdukeys.append(int(ext))
            except ValueError:
                parts = ext.split(',')
                if (len(parts) > 1):
                    extname = ','.join(parts[0:(-1)])
                    extver = int(parts[(-1)])
                    hdukeys.append((extname, extver))
                else:
                    hdukeys.append(ext)
    return self._parse_internal(hdukeys, keywords, compressed)
