Remove from sys.modules the modules imported by the debuggee.
519025
def reset(self):
        """"""
        if not self.hooked:
            self.hooked = True
            sys.path_hooks.append(self)
            sys.path.insert(0, self.PATH_ENTRY)
            return

        for modname in self:
            if modname in sys.modules:
                del sys.modules[modname]
                submods = []
                for subm in sys.modules:
                    if subm.startswith(modname + '.'):
                        submods.append(subm)
                # All submodules of modname may not have been imported by the
                # debuggee, but they are still removed from sys.modules as
                # there is no way to distinguish them.
                for subm in submods:
                    del sys.modules[subm]
        self[:] = []
1127768
def unregister_module(self, module):
        

        if module not in self._modules:
            raise NoRegisteredError("Module '{0}' is not registered on loader.".format(module))

        self._modules.remove(module)
79757
def stop_all(self):
        
        logger.info('Shutting down modules...')
        # Ask internal to quit if they can
        for instance in self.get_internal_instances():
            if hasattr(instance, 'quit') and isinstance(instance.quit, collections.Callable):
                instance.quit()

        self.clear_instances([instance for instance in self.instances if instance.is_external])
1087919
@SuppressWarnings("PMD.UseVarargs")
    public void disableModules(final Class<? extends Module>[] modules) {
        for (Class<? extends Module> module : modules) {
            registerDisable(ConfigItem.Module, module);
        }
    }
1333507
public function removeAllByModule($module)
    {
        foreach ($this->getIndexesByModule($module) as $index) {
            if (isset($this->data[$index])) {
                unset($this->data[$index]);
            }
        }
    }
384624
private function removeEmptySections()
    {
        $sections = [$this::IMPORTS_SECTION, $this::SERVICE_SECTION];
        foreach ($sections as $section) {
            if (array_key_exists($section, $this->configArray) &&
                (!$this->configArray[$section] || !count($this->configArray[$section]))) {
                unset($this->configArray[$section]);
            }
        }
    }
392726
function unloadModule (module) {
    var found_module = false;

    registered_modules = _.reject(registered_modules, function (registered_module) {
        if (module.toLowerCase() === registered_module.module_name.toLowerCase()) {
            found_module = true;

            registered_module.dispose();
            return true;
        }
    });

    return found_module;
}
608887
def disable_site_packages():
    
    for entry in sys.path[:]:
        if 'site-packages' in entry or 'Extras' in entry:
            sys.path.remove(entry)
618259
public void unloadModule(Module module) {
        Objects.requireNonNull(module, "module");
        unloadModuleLocal(module);
        moduleSpecs.remove(module.getIdentifier());
    }
444174
def _remove(self, args):
        '''
        
        '''
        if len(args) < 2:
            raise SPMInvocationError('A package must be specified')

        packages = args[1:]
        msg = 'Removing packages:\n\t{0}'.format('\n\t'.join(packages))

        if not self.opts['assume_yes']:
            self.ui.confirm(msg)

        for package in packages:
            self.ui.status('... removing {0}'.format(package))

            if not self._pkgdb_fun('db_exists', self.opts['spm_db']):
                raise SPMDatabaseError('No database at {0}, cannot remove {1}'.format(self.opts['spm_db'], package))

            # Look at local repo index
            pkg_info = self._pkgdb_fun('info', package, self.db_conn)
            if pkg_info is None:
                raise SPMInvocationError('Package {0} not installed'.format(package))

            # Find files that have not changed and remove them
            files = self._pkgdb_fun('list_files', package, self.db_conn)
            dirs = []
            for filerow in files:
                if self._pkgfiles_fun('path_isdir', filerow[0]):
                    dirs.append(filerow[0])
                    continue
                file_hash = hashlib.sha1()
                digest = self._pkgfiles_fun('hash_file', filerow[0], file_hash, self.files_conn)
                if filerow[1] == digest:
                    self._verbose('Removing file {0}'.format(filerow[0]), log.trace)
                    self._pkgfiles_fun('remove_file', filerow[0], self.files_conn)
                else:
                    self._verbose('Not removing file {0}'.format(filerow[0]), log.trace)
                self._pkgdb_fun('unregister_file', filerow[0], package, self.db_conn)

            # Clean up directories
            for dir_ in sorted(dirs, reverse=True):
                self._pkgdb_fun('unregister_file', dir_, package, self.db_conn)
                try:
                    self._verbose('Removing directory {0}'.format(dir_), log.trace)
                    os.rmdir(dir_)
                except OSError:
                    # Leave directories in place that still have files in them
                    self._verbose('Cannot remove directory {0}, probably not empty'.format(dir_), log.trace)

            self._pkgdb_fun('unregister_pkg', package, self.db_conn)
686565
def unload_module(self, module_name):
        """"""
        module = self.loaded_modules.get(module_name)
        if not module:
            _log.warning("Ignoring request to unload non-existant module '%s'",
                         module_name)
            return False

        module.stop(reloading=False)
        del self.loaded_modules[module_name]
        self.module_ordering.remove(module_name)
        return True
1172575
public void removeSamePackage (String pkg)
    {
        Iterator<String> i = _imports.iterator();
        while (i.hasNext()) {
            String name = i.next();
            if (name.startsWith(pkg) &&
                name.indexOf('.', pkg.length() + 1) == -1) {
                    i.remove();
            }
        }
    }
1096832
public void clearRegisteredModules()
    {
        ServletContext servletContext = getServletContext();
        
        for ( Iterator ii = _registeredModules.keySet().iterator(); ii.hasNext(); )  
        {
            String modulePrefix = ( String ) ii.next();
            servletContext.removeAttribute( Globals.MODULE_KEY + modulePrefix );
            servletContext.removeAttribute( Globals.REQUEST_PROCESSOR_KEY + modulePrefix );
        }
        
        _registeredModules.clear();
    }
40144
def purge_module(self, module_name):
        
        containers = self.config["py3_config"][".module_groups"]
        containers_to_update = set()
        if module_name in containers:
            containers_to_update.update(set(containers[module_name]))
        for container in containers_to_update:
            try:
                self.modules[container].module_class.items.remove(module_name)
            except ValueError:
                pass
1036678
public synchronized void removeScriptModule(ModuleId scriptModuleId) {
        jbossModuleLoader.unloadAllModuleRevision(scriptModuleId.toString());
        ScriptModule oldScriptModule = loadedScriptModules.remove(scriptModuleId);
        if (oldScriptModule != null) {
            notifyModuleUpdate(null, oldScriptModule);
        }
    }
829083
def delete_module(modname):
    
    try:
        _ = sys.modules[modname]
    except KeyError:
        raise ValueError("Module not found in sys.modules: '{}'".format(modname))

    for module in list(sys.modules.keys()):
        if module and module.startswith(modname):
            del sys.modules[module]
865487
def unregister_finders():
  """"""

  global __PREVIOUS_FINDER
  if not __PREVIOUS_FINDER:
    return

  pkg_resources.register_finder(zipimport.zipimporter, __PREVIOUS_FINDER)
  _remove_finder(pkgutil.ImpImporter, find_wheels_on_path)

  if importlib_machinery is not None:
    _remove_finder(importlib_machinery.FileFinder, find_wheels_on_path)

  __PREVIOUS_FINDER = None