'The meat of the formatting; in a separate method to allow overriding.'

def _parse_internal(self, hdukeys, keywords, compressed):

    result = []
    for (idx, hdu) in enumerate(hdukeys):
        try:
            cards = self._get_cards(hdu, keywords, compressed)
        except ExtensionNotFoundException:
            continue
        if (idx > 0):
            result.append('\n')
        result.append('#    HDU    {}    in    {}:\n'.format(hdu, self.filename))
        for c in cards:
            result.append('{}\n'.format(c))
    return ''.join(result)
