sys.meta_path.remove

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 7

Example 1

Project: imagrium Source File: test_import_pep328.py
Function: tear_down
    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]

Example 2

Project: cython Source File: pyximport.py
Function: uninstall
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

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)

Example 4

Project: typesafety Source File: finder.py
Function: uninstall
    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()

Example 5

Project: urllib3 Source File: test_no_ssl.py
Function: tear_down
    def tearDown(self):
        sys.meta_path.remove(ssl_blocker)
        module_stash.pop()

Example 6

Project: pynsive Source File: manager.py
Function: destroy
    def destroy(self):
        """
        Removes the meta_path hook associated with this manager.
        """
        sys.meta_path.remove(self.finder)

Example 7

Project: bitey Source File: loader.py
Function: remove
def remove():
    sys.meta_path.remove(LLVMLoader)

Example 8

Project: attest Source File: hook.py
Function: exit
    def __exit__(self, exc_type, exc_value, traceback):
        sys.meta_path.remove(self)

Example 9

Project: pyp2rpm Source File: __init__.py
Function: pytest_unconfigure
def pytest_unconfigure(config):
    hook = config._assertstate.hook
    if hook is not None:
        sys.meta_path.remove(hook)

Example 10

Project: pyhackedit Source File: util.py
Function: exit
    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

Example 11

Project: private-readthedocs.org Source File: hacks.py
def unpatch_meta_path():
    sys.meta_path.remove(FreeLoader._class)

Example 12

Project: shellpy Source File: importer.py
Function: load_module
    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

Example 13

Project: shellpy Source File: __init__.py
Function: uninit
def uninit():
    """Uninitialize shellpython by removing the import hook
    """
    sys.meta_path.remove(_importer)

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)

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)

Example 16

Project: keystonemiddleware Source File: utils.py
Function: tear_down
    def tearDown(self):
        super(DisableModuleFixture, self).tearDown()
        for finder in self._finders:
            sys.meta_path.remove(finder)
        sys.modules.update(self._cleared_modules)