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.

28 Examples 7

Example 1

Project: imagrium
Source File: test_import_pep328.py
View license
    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
View license
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
View license
    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: archivczsk
Source File: contentprovider.py
View license
    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 5

View license
    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 6

View license
    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 7

Project: medicare-demo
Source File: test_import_pep328.py
View license
    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 8

Project: typesafety
Source File: finder.py
View license
    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 9

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

Example 10

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

Example 11

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

Example 12

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

Example 13

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

Example 14

Project: pyhackedit
Source File: util.py
View license
    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 15

Project: Nagstamon
Source File: util.py
View license
    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 16

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

Example 17

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

Example 18

Project: shellpy
Source File: importer.py
View license
    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 19

Project: shellpy
Source File: importer.py
View license
    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 20

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

Example 21

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

Example 22

Project: archivczsk
Source File: addon.py
View license
    def remove_importer(self):
        log.debug("%s removing importer" , self.addon)
        sys.meta_path.remove(self.__importer)

Example 23

Project: archivczsk
Source File: addon.py
View license
    def remove_importer(self):
        log.debug("%s removing importer" , self.addon)
        sys.meta_path.remove(self.__importer)

Example 24

Project: archivczsk
Source File: contentprovider.py
View license
    def __pause_resolving_provider(self):
        self.video_addon.deinclude()
        for addon in self._dependencies:
            addon.deinclude()
        sys.meta_path.remove(self._sys_importer)

Example 25

Project: archivczsk
Source File: contentprovider.py
View license
    def __pause_resolving_provider(self):
        self.video_addon.deinclude()
        for addon in self._dependencies:
            addon.deinclude()
        sys.meta_path.remove(self._sys_importer)

Example 26

Project: OpenCobolIDE
Source File: util.py
View license
    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 27

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

Example 28

Project: python-keystoneclient
Source File: utils.py
View license
    def tearDown(self):
        super(DisableModuleFixture, self).tearDown()
        for finder in self._finders:
            sys.meta_path.remove(finder)
        sys.modules.update(self._cleared_modules)