sys.path_hooks.append

Here are the examples of the python api sys.path_hooks.append taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

7 Examples 7

Example 1

Project: codegenloader Source File: base.py
Function: install_hook
    @classmethod
    def _install_hook(cls):
        """Installs this loader as a ``path_hook``."""
        if hasattr(cls, "_hook_installed"):
            return
        sys.path_hooks.append(cls)
        cls._hook_installed = True

Example 2

Project: Ivoire Source File: transform.py
    @classmethod
    def register(cls):
        """
        Register the path hook.

        """

        cls._finder = FileFinder.path_hook((cls, [cls.suffix]))
        sys.path_hooks.append(cls._finder)

Example 3

Project: pymo Source File: test_importhooks.py
Function: testpathhook
    def testPathHook(self):
        sys.path_hooks.append(PathImporter)
        sys.path.append(test_path)
        self.doTestImports()

Example 4

Project: TrustRouter Source File: test_threaded_import.py
Function: test_parallel_path_hooks
    def test_parallel_path_hooks(self):
        # Here the Finder instance is only used to check concurrent calls
        # to path_hook().
        finder = Finder()
        # In order for our path hook to be called at each import, we need
        # to flush the path_importer_cache, which we do by registering a
        # dedicated meta_path entry.
        flushing_finder = FlushingFinder()
        def path_hook(path):
            finder.find_module('')
            raise ImportError
        sys.path_hooks.append(path_hook)
        sys.meta_path.append(flushing_finder)
        try:
            # Flush the cache a first time
            flushing_finder.find_module('')
            numtests = self.check_parallel_module_init()
            self.assertGreater(finder.numcalls, 0)
            self.assertEqual(finder.x, finder.numcalls)
        finally:
            sys.meta_path.remove(flushing_finder)
            sys.path_hooks.remove(path_hook)

Example 5

Project: badideas Source File: githubimporter.py
Function: install_hook
def install_hook():
    sys.path_hooks.append(GithubImporter)

Example 6

Project: python-git-orm Source File: test_importer.py
Function: setup_module
def setup_module():
    sys.path_hooks.append(GitImporter)
    sys.path.append('{}/config'.format(PATH_PREFIX))

Example 7

Project: phpsploit Source File: stateMachine2.py
Function: register
    @classmethod
    def register(cls):
        sys.path_hooks.append(cls)
        sys.path.append(cls.trigger_url())