

def module_has_submodule(package, module_name):
    "See if 'module' is in 'package'."
    name = '.'.join([package.__name__, module_name])
    try:
        return (sys.modules[name] is not None)
    except KeyError:
        pass
    try:
        package_path = package.__path__
    except AttributeError:
        return False
    for finder in sys.meta_path:
        if finder.find_module(name, package_path):
            return True
    for entry in package_path:
        try:
            finder = sys.path_importer_cache[entry]
            if (finder is None):
                try:
                    (file_, _, _) = imp.find_module(module_name, [entry])
                    if file_:
                        package_path.close()
                    return True
                except ImportError:
                    continue
            elif finder.find_module(name):
                return True
            else:
                continue
        except KeyError:
            for hook in sys.path_hooks:
                try:
                    finder = hook(entry)
                    if finder.find_module(name):
                        return True
                    else:
                        break
                except ImportError:
                    continue
            else:
                if os.path.isdir(entry):
                    try:
                        (file_, _, _) = imp.find_module(module_name, [entry])
                        if file_:
                            file_.close()
                        return True
                    except ImportError:
                        pass
    else:
        return False

dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/Django-1.6.10/django/utils/module_loading.py module_has_submodule/VarMisuse@158/211 `file_`->`package_path`