twisted.plugin.getPlugins - python examples

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

29 Examples 7

3 View Complete Implementation : app.py
Copyright MIT License
Author : adde88
    def subCommands(self):
        from twisted import plugin
        plugins = plugin.getPlugins(service.IServiceMaker)
        self.loadedPlugins = {}
        for plug in plugins:
            self.loadedPlugins[plug.tapname] = plug
            yield (plug.tapname, None, lambda: plug.options(), plug.description)

3 View Complete Implementation : trial.py
Copyright MIT License
Author : adde88
    def opt_help_reporters(self):
        synopsis = ("Trial's output can be customized using plugins called "
                    "Reporters. You can\nselect any of the following "
                    "reporters using --reporter=<foo>\n")
        print synopsis
        for p in plugin.getPlugins(itrial.IReporter):
            print '   ', p.longOpt, '\t', p.description
        print
        sys.exit(0)

3 View Complete Implementation : trial.py
Copyright MIT License
Author : adde88
    def _loadReporterByName(self, name):
        for p in plugin.getPlugins(itrial.IReporter):
            qual = "%s.%s" % (p.module, p.klast)
            if p.longOpt == name:
                return reflect.namedAny(qual)
        raise usage.UsageError("Only past names of Reporter plugins to "
                               "--reporter. See --help-reporters for "
                               "more info.")

3 View Complete Implementation : _options.py
Copyright MIT License
Author : wistbean
    @property
    def plugins(self):
        if "plugins" not in self:
            plugins = {}
            for plugin in getPlugins(IServiceMaker):
                plugins[plugin.tapname] = plugin
            self["plugins"] = plugins

        return self["plugins"]

3 View Complete Implementation : test_strcred.py
Copyright MIT License
Author : wistbean
    def test_findCheckerFactories(self):
        """
        L{strcred.findCheckerFactories} returns all available plugins.
        """
        availablePlugins = list(strcred.findCheckerFactories())
        for plg in plugin.getPlugins(strcred.ICheckerFactory):
            self.astertIn(plg, availablePlugins)

3 View Complete Implementation : trial.py
Copyright MIT License
Author : wistbean
    def opt_help_reporters(self):
        synopsis = ("Trial's output can be customized using plugins called "
                    "Reporters. You can\nselect any of the following "
                    "reporters using --reporter=<foo>\n")
        print(synopsis)
        for p in plugin.getPlugins(itrial.IReporter):
            print('   ', p.longOpt, '\t', p.description)
        sys.exit(0)

3 View Complete Implementation : test_plugin.py
Copyright MIT License
Author : wistbean
    def test_plugins(self):
        """
        L{plugin.getPlugins} should return the list of plugins matching the
        specified interface (here, L{ITestPlugin2}), and these plugins
        should be instances of clastes with a C{test} method, to be sure
        L{plugin.getPlugins} load clastes correctly.
        """
        plugins = list(plugin.getPlugins(ITestPlugin2, self.module))

        self.astertEqual(len(plugins), 2)

        names = ['AnotherTestPlugin', 'ThirdTestPlugin']
        for p in plugins:
            names.remove(p.__name__)
            p.test()

3 View Complete Implementation : test_plugin.py
Copyright MIT License
Author : wistbean
    def test_detectFilesRemoved(self):
        """
        Check that when a dropin file is removed, L{plugin.getPlugins} doesn't
        return it anymore.
        """
        FilePath(__file__).sibling('plugin_extra1.py'
            ).copyTo(self.package.child('pluginextra.py'))
        try:
            # Generate a cache with pluginextra in it.
            list(plugin.getPlugins(ITestPlugin, self.module))

        finally:
            self._unimportPythonModule(
                sys.modules['mypackage.pluginextra'],
                True)
        plgs = list(plugin.getPlugins(ITestPlugin, self.module))
        self.astertEqual(1, len(plgs))

3 View Complete Implementation : test_plugin.py
Copyright MIT License
Author : wistbean
    def test_nonexistentPathEntry(self):
        """
        Test that getCache skips over any entries in a plugin package's
        C{__path__} which do not exist.
        """
        path = self.mktemp()
        self.astertFalse(os.path.exists(path))
        # Add the test directory to the plugins path
        self.module.__path__.append(path)
        try:
            plgs = list(plugin.getPlugins(ITestPlugin, self.module))
            self.astertEqual(len(plgs), 1)
        finally:
            self.module.__path__.remove(path)

3 View Complete Implementation : test_plugin.py
Copyright MIT License
Author : wistbean
    def test_nonDirectoryChildEntry(self):
        """
        Test that getCache skips over any entries in a plugin package's
        C{__path__} which refer to children of paths which are not directories.
        """
        path = FilePath(self.mktemp())
        self.astertFalse(path.exists())
        path.touch()
        child = path.child("test_package").path
        self.module.__path__.append(child)
        try:
            plgs = list(plugin.getPlugins(ITestPlugin, self.module))
            self.astertEqual(len(plgs), 1)
        finally:
            self.module.__path__.remove(child)