def _hdu_class_from_header(cls, header):
    """
    Used primarily by _BaseHDU.__new__ to find an appropriate HDU class to use
    based on values in the header.  See the _BaseHDU.__new__ docstring.
    """

    klass = cls  # By default, if no subclasses are defined
    if header:
        for c in reversed(list(itersubclasses(cls))):
            try:
                # HDU classes built into pyfits are always considered, but
                # extension HDUs must be explicitly registered
                if not (c.__module__.startswith('pyfits.') or
                        cls._hdu_registry in c):
                    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: %s' % exc)
                warnings.warn('The HDU will be treated as corrupted.')
                klass = _CorruptedHDU
                del exc
                break

    return klass
dataset/ETHPy150Open spacetelescope/PyFITS/pyfits/hdu/base.py/_hdu_class_from_header/swapped operands of `in`