def stub_if_missing_deps(*deps):
    """A class decorator that will try to import the specified modules and in
    the event of failure will stub out the class, raising a RuntimeError that
    explains the missing dependencies whenever an attempt is made to
    instantiate the class.
    
    deps: str args
        args in deps may have the form a.b.c or a.b.c:attr, where attr would be 
        searched for within the module a.b.c after a.b.c is successfully imported.
    """
    
    def _find_failed_imports():
        failed = []
        for dep in deps:
            parts = dep.split(':')
            modname = parts[0]
            attrname = parts[1] if len(parts)>1 else None
            
            try:
                __import__(modname)
            except __HOLE__ as err:
                failed.append(str(err).split()[-1])
                continue
            
            if attrname and not hasattr(sys.modules[modname], attrname):
                failed.append('.'.join([modname, attrname]))
        return failed
    
    def _stub_if_missing(obj):
        failed = _find_failed_imports()        
        if failed:
            if isclass(obj):
                def _error(obj, *args, **kwargs):
                    msg = "The %s class depends on the following modules or attributes which were not found on your system: %s"
                    raise RuntimeError(msg % (obj.__name__, failed))
                obj.__new__ = staticmethod(_error)
            elif isfunction(obj):
                body = "raise RuntimeError(\"The %s function depends on the following modules or attributes which were not found on your system: %s\")" 
                return replace_funct(obj, body % (obj.__name__, failed))
        return obj
            
    return _stub_if_missing
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.util/src/openmdao/util/decorators.py/stub_if_missing_deps