当前位置: 首页>>代码示例>>Python>>正文


Python plugin.getPlugins方法代码示例

本文整理汇总了Python中twisted.plugin.getPlugins方法的典型用法代码示例。如果您正苦于以下问题:Python plugin.getPlugins方法的具体用法?Python plugin.getPlugins怎么用?Python plugin.getPlugins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.plugin的用法示例。


在下文中一共展示了plugin.getPlugins方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_detectFilesRemoved

# 需要导入模块: from twisted import plugin [as 别名]
# 或者: from twisted.plugin import getPlugins [as 别名]
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.assertEqual(1, len(plgs)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:19,代码来源:test_plugin.py

示例2: test_hiddenPackageSamePluginModuleNameObscured

# 需要导入模块: from twisted import plugin [as 别名]
# 或者: from twisted.plugin import getPlugins [as 别名]
def test_hiddenPackageSamePluginModuleNameObscured(self):
        """
        Only plugins from the first package in sys.path should be returned by
        getPlugins in the case where there are two Python packages by the same
        name installed, each with a plugin module by a single name.
        """
        root = FilePath(self.mktemp())
        root.makedirs()

        firstDirectory = self.createDummyPackage(root, 'first', 'someplugin')
        secondDirectory = self.createDummyPackage(root, 'second', 'someplugin')

        sys.path.append(firstDirectory.path)
        sys.path.append(secondDirectory.path)

        import dummy.plugins

        plugins = list(plugin.getPlugins(ITestPlugin, dummy.plugins))
        self.assertEqual(['first'], [p.__name__ for p in plugins]) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:21,代码来源:test_plugin.py

示例3: test_hiddenPackageDifferentPluginModuleNameObscured

# 需要导入模块: from twisted import plugin [as 别名]
# 或者: from twisted.plugin import getPlugins [as 别名]
def test_hiddenPackageDifferentPluginModuleNameObscured(self):
        """
        Plugins from the first package in sys.path should be returned by
        getPlugins in the case where there are two Python packages by the same
        name installed, each with a plugin module by a different name.
        """
        root = FilePath(self.mktemp())
        root.makedirs()

        firstDirectory = self.createDummyPackage(root, 'first', 'thisplugin')
        secondDirectory = self.createDummyPackage(root, 'second', 'thatplugin')

        sys.path.append(firstDirectory.path)
        sys.path.append(secondDirectory.path)

        import dummy.plugins

        plugins = list(plugin.getPlugins(ITestPlugin, dummy.plugins))
        self.assertEqual(['first'], [p.__name__ for p in plugins]) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:21,代码来源:test_plugin.py

示例4: getProcessor

# 需要导入模块: from twisted import plugin [as 别名]
# 或者: from twisted.plugin import getPlugins [as 别名]
def getProcessor(input, output, config):
    plugins = plugin.getPlugins(IProcessor)
    for plug in plugins:
        if plug.name == input:
            module = reflect.namedModule(plug.moduleName)
            break
    else:
        # try treating it as a module name
        try:
            module = reflect.namedModule(input)
        except ImportError:
            print '%s: no such input: %s' % (sys.argv[0], input)
            return
    try:
        return process.getProcessor(module, output, config)
    except process.NoProcessorError, e:
        print "%s: %s" % (sys.argv[0], e) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:19,代码来源:lore.py

示例5: test_detectFilesRemoved

# 需要导入模块: from twisted import plugin [as 别名]
# 或者: from twisted.plugin import getPlugins [as 别名]
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.assertEquals(1, len(plgs)) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:19,代码来源:test_plugin.py

示例6: getProcessor

# 需要导入模块: from twisted import plugin [as 别名]
# 或者: from twisted.plugin import getPlugins [as 别名]
def getProcessor(input, output, config):
    plugins = oldplugin._getPlugIns("lore")
    for plug in plugins:
        if plug.tapname == input:
            module = plug.load()
            break
    else:
        plugins = newplugin.getPlugins(IProcessor)
        for plug in plugins:
            if plug.name == input:
                module = reflect.namedModule(plug.moduleName)
                break
        else:
            # try treating it as a module name
            try:
                module = reflect.namedModule(input)
            except ImportError:
                print '%s: no such input: %s' % (sys.argv[0], input)
                return
    try:
        return process.getProcessor(module, output, config)
    except process.NoProcessorError, e:
        print "%s: %s" % (sys.argv[0], e) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:25,代码来源:lore.py

示例7: do

# 需要导入模块: from twisted import plugin [as 别名]
# 或者: from twisted.plugin import getPlugins [as 别名]
def do(self, player, line, typeName, name, description=None, article=None):
        """
        Create an item, and notify everyone present that it now exists.
        """
        if not description:
            description = u'an undescribed object'
        for plug in getPlugins(IThingType, imaginary.plugins):
            if plug.type == typeName:
                proper = (article == "the")
                o = plug.getType()(store=player.store, name=name,
                                   description=description, proper=proper)
                break
        else:
            raise ActionFailure(
                events.ThatDoesntMakeSense(
                    actor=player.thing,
                    actorMessage=language.ExpressString(
                        u"Can't find " + typeName + u".")))

        creationSuccess(player.thing, o).broadcast()
        try:
            o.moveTo(player.thing)
        except DoesntFit:
            raise insufficientSpace(player.thing) 
开发者ID:twisted,项目名称:imaginary,代码行数:26,代码来源:creation.py

示例8: test_pluginDiscovery

# 需要导入模块: from twisted import plugin [as 别名]
# 或者: from twisted.plugin import getPlugins [as 别名]
def test_pluginDiscovery(self):
        """
        L{endpoints._SystemdParser} is found as a plugin for
        L{interfaces.IStreamServerEndpointStringParser} interface.
        """
        parsers = list(getPlugins(
            interfaces.IStreamServerEndpointStringParser))

        for p in parsers:
            if isinstance(p, self._parserClass):
                break
        else:
            self.fail("Did not find systemd parser in %r" % (parsers,)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:15,代码来源:test_endpoints.py

示例9: plugins

# 需要导入模块: from twisted import plugin [as 别名]
# 或者: from twisted.plugin import getPlugins [as 别名]
def plugins(self):
        if "plugins" not in self:
            plugins = {}
            for plugin in getPlugins(IServiceMaker):
                plugins[plugin.tapname] = plugin
            self["plugins"] = plugins

        return self["plugins"] 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:10,代码来源:_options.py

示例10: getReactorTypes

# 需要导入模块: from twisted import plugin [as 别名]
# 或者: from twisted.plugin import getPlugins [as 别名]
def getReactorTypes():
    """
    Return an iterator of L{IReactorInstaller} plugins.
    """
    return getPlugins(IReactorInstaller) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:7,代码来源:reactors.py

示例11: test_findCheckerFactories

# 需要导入模块: from twisted import plugin [as 别名]
# 或者: from twisted.plugin import getPlugins [as 别名]
def test_findCheckerFactories(self):
        """
        Test that findCheckerFactories returns all available plugins.
        """
        availablePlugins = list(strcred.findCheckerFactories())
        for plg in plugin.getPlugins(strcred.ICheckerFactory):
            self.assertIn(plg, availablePlugins) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:9,代码来源:test_strcred.py

示例12: setUp

# 需要导入模块: from twisted import plugin [as 别名]
# 或者: from twisted.plugin import getPlugins [as 别名]
def setUp(self):
        self.config = trial.Options()
        # whitebox hack a reporter in, because plugins are CACHED and will
        # only reload if the FILE gets changed.

        parts = reflect.qual(CapturingReporter).split('.')
        package = '.'.join(parts[:-1])
        klass = parts[-1]
        plugins = [twisted_trial._Reporter(
            "Test Helper Reporter",
            package,
            description="Utility for unit testing.",
            longOpt="capturing",
            shortOpt=None,
            klass=klass)]


        # XXX There should really be a general way to hook the plugin system
        # for tests.
        def getPlugins(iface, *a, **kw):
            self.assertEqual(iface, IReporter)
            return plugins + list(self.original(iface, *a, **kw))

        self.original = plugin.getPlugins
        plugin.getPlugins = getPlugins

        self.standardReport = ['startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest'] 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:38,代码来源:test_runner.py

示例13: tearDown

# 需要导入模块: from twisted import plugin [as 别名]
# 或者: from twisted.plugin import getPlugins [as 别名]
def tearDown(self):
        plugin.getPlugins = self.original 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:4,代码来源:test_runner.py

示例14: getPluginsByLongOption

# 需要导入模块: from twisted import plugin [as 别名]
# 或者: from twisted.plugin import getPlugins [as 别名]
def getPluginsByLongOption(self, longOption):
        """
        Return the Trial reporter plugin with the given long option.

        If more than one is found, raise ValueError. If none are found, raise
        IndexError.
        """
        plugins = [
            plugin for plugin in getPlugins(IReporter)
            if plugin.longOpt == longOption]
        if len(plugins) > 1:
            raise ValueError(
                "More than one plugin found with long option %r: %r"
                % (longOption, plugins))
        return plugins[0] 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:17,代码来源:test_plugins.py

示例15: test_plugins

# 需要导入模块: from twisted import plugin [as 别名]
# 或者: from twisted.plugin import getPlugins [as 别名]
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 classes with a C{test} method, to be sure
        L{plugin.getPlugins} load classes correctly.
        """
        plugins = list(plugin.getPlugins(ITestPlugin2, self.module))

        self.assertEqual(len(plugins), 2)

        names = ['AnotherTestPlugin', 'ThirdTestPlugin']
        for p in plugins:
            names.remove(p.__name__)
            p.test() 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:17,代码来源:test_plugin.py


注:本文中的twisted.plugin.getPlugins方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。