def _hdu_class_from_header(cls, header):
 klass = cls
 if header:
  for c in reversed(list(itersubclasses(cls))):
   try:
    if (not (c.__module__.startswith('astropy.io.fits.') or (c in cls._hdu_registry))):
     continue
    if c.match_header(header):
     klass = c
     break
   except NotImplementedError:
    continue
   except Exception as exc:
    warnings.warn('An exception occurred matching an HDU header to the appropriate HDU type: {0}'.format(exc), AstropyUserWarning)
    warnings.warn('The HDU will be treated as corrupted.', AstropyUserWarning)
    klass = _CorruptedHDU
    del exc
    break
 return klass

def _hdu_class_from_header ( cls , header ) : klass = cls if header : for c in reversed ( list ( itersubclasses ( cls ) ) ) : try : if ( not ( c . __module__ . startswith ( 'astropy.io.fits.' ) or ( c in cls . _hdu_registry ) ) ) : continue if c . match_header ( header ) : klass = c break except NotImplementedError : continue except Exception as exc : warnings . warn ( 'An exception occurred matching an HDU header to the appropriate HDU type: {0}' . format ( exc ) , AstropyUserWarning ) warnings . warn ( 'The HDU will be treated as corrupted.' , AstropyUserWarning ) klass = _CorruptedHDU del exc break return klass
used primarily by _basehdu .