#NEWLINE# def _get_cards( self , hdukey , keywords , compressed ) : #NEWLINE# #INDENT# "Returns a list of `pyfits.card.Card` objects.\n\n        This function will return the desired header cards, taking into\n        account the user's preference to see the compressed or uncompressed\n        version.\n\n        Parameters\n        ----------\n        hdukey : int or str\n            Key of a single HDU in the HDUList.\n\n        keywords : list of str, optional\n            Keywords for which the cards should be returned.\n\n        compressed : boolean, optional\n            If True, shows the header describing the compression.\n\n        Raises\n        ------\n        ExtensionNotFoundException\n            If the hdukey does not correspond to an extension.\n        " #NEWLINE# try : #NEWLINE# #INDENT# if compressed : #NEWLINE# #INDENT# header = self . _hdulist [ hdukey ] . _header #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# header = self . _hdulist [ hdukey ] . header #NEWLINE# #UNINDENT# #UNINDENT# except ( IndexError , KeyError ) : #NEWLINE# #INDENT# message = '{0}: Extension {1} not found.' . format ( self . filename , hdukey ) #NEWLINE# log . warning ( message ) #NEWLINE# raise ExtensionNotFoundException ( message ) #NEWLINE# #UNINDENT# if ( not keywords ) : #NEWLINE# #INDENT# cards = header . cards #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# cards = [ ] #NEWLINE# for kw in keywords : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# crd = header . cards [ kw ] #NEWLINE# if isinstance ( crd , pyfits . card . Card ) : #NEWLINE# #INDENT# cards . append ( crd ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# cards . extend ( crd ) #NEWLINE# #UNINDENT# #UNINDENT# except KeyError as e : #NEWLINE# #INDENT# log . warning ( '{filename} (HDU {hdukey}): Keyword {kw} not found.' . format ( filename = self . filename , hdukey = hdukey , kw = kw ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return cards