Here are the examples of the python api sys.meta_path.remove taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
16 Examples
3
Example 1
def tearDown(self):
try:
sys.meta_path.remove(self)
except ValueError:
pass
for k in sys.modules.keys():
if k.startswith(self.nameX):
del sys.modules[k]
3
Example 2
def uninstall(py_importer, pyx_importer):
"""
Uninstall an import hook.
"""
try:
sys.meta_path.remove(py_importer)
except ValueError:
pass
try:
sys.meta_path.remove(pyx_importer)
except ValueError:
pass
3
Example 3
Project: archivczsk Source File: contentprovider.py
def __unset_resolving_provider(self):
VideoAddonContentProvider.__resolving_provider = None
VideoAddonContentProvider.__addon_sys.clear_addons()
self.video_addon.deinclude()
self.release_dependencies()
sys.meta_path.remove(self._sys_importer)
0
Example 4
def uninstall(self):
'''
Uninstall the module finder. If not installed, this will do nothing.
After uninstallation, none of the newly loaded modules will be
decorated (that is, everything will be back to normal).
'''
if self.installed:
sys.meta_path.remove(self)
# Reload all decorated items
import_list = []
for name in self.__loaded_modules:
del sys.modules[name]
import_list.append(name)
for name in import_list:
__import__(name)
self.__reset()
0
Example 5
def tearDown(self):
sys.meta_path.remove(ssl_blocker)
module_stash.pop()
0
Example 6
def destroy(self):
"""
Removes the meta_path hook associated with this manager.
"""
sys.meta_path.remove(self.finder)
0
Example 7
def remove():
sys.meta_path.remove(LLVMLoader)
0
Example 8
def __exit__(self, exc_type, exc_value, traceback):
sys.meta_path.remove(self)
0
Example 9
def pytest_unconfigure(config):
hook = config._assertstate.hook
if hook is not None:
sys.meta_path.remove(hook)
0
Example 10
def __exit__(self, *args):
sys.meta_path.remove(self)
for key, value in self.original.items():
if value is not None:
sys.modules[key] = value
0
Example 11
Project: private-readthedocs.org Source File: hacks.py
def unpatch_meta_path():
sys.meta_path.remove(FreeLoader._class)
0
Example 12
def load_module(self, module_name):
"""If the module was located it then is loaded by this function. It is also a part of PEP-0302 interface
Loading means first preprocessing of shell python code if it is not processed already and the addition
to system path and import.
:param module_name: the name of the module to load
:return: the module imported. This function assumes that it will import a module anyway since find_module
already found the module
"""
sys.meta_path.remove(self)
if module_name.find('.') == -1:
spy_module_path = locator.locate_spy_module(module_name)
spy_file_path = locator.locate_spy_file(module_name)
if spy_module_path is not None:
new_module_path = preprocessor.preprocess_module(spy_module_path)
new_module_pythonpath = os.path.split(new_module_path)[0]
if new_module_pythonpath not in sys.path:
sys.path.append(new_module_pythonpath)
module = import_module(module_name)
elif spy_file_path is not None:
new_module_path = preprocessor.preprocess_file(spy_file_path, is_root_script=False)
new_module_pythonpath = os.path.split(new_module_path)[0]
if new_module_pythonpath not in sys.path:
sys.path.append(new_module_pythonpath)
module = import_module(module_name)
else:
raise ImportError("Unexpected error occured in importer. Neither shellpy module not file was found")
else:
module = import_module(module_name)
sys.meta_path.insert(0, self)
return module
0
Example 13
def uninit():
"""Uninitialize shellpython by removing the import hook
"""
sys.meta_path.remove(_importer)
0
Example 14
Project: archivczsk Source File: addon.py
def remove_importer(self):
log.debug("%s removing importer" , self.addon)
sys.meta_path.remove(self.__importer)
0
Example 15
Project: archivczsk Source File: contentprovider.py
def __pause_resolving_provider(self):
self.video_addon.deinclude()
for addon in self._dependencies:
addon.deinclude()
sys.meta_path.remove(self._sys_importer)
0
Example 16
def tearDown(self):
super(DisableModuleFixture, self).tearDown()
for finder in self._finders:
sys.meta_path.remove(finder)
sys.modules.update(self._cleared_modules)