def _import(self, typ):
        """Return class for *typ*."""
        if typ not in self._ctors:
            parts = typ.split('.')
            cname = parts[-1]
            modname = '.'.join(parts[:-1])
            try:
                __import__(modname, globals(), locals(), [cname])
                mod = sys.modules[modname]
            except (ImportError, KeyError) as err:
                logger.error(str(err))
                return None
            try:
                self._ctors[typ] = getattr(mod, cname)
            except AttributeError as err:
                logger.error(str(err))
                return None
        
        return self._ctors[typ]
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.main/src/openmdao/main/importfactory.py/ImportFactory._import/original