Python twisted.plugin.getPlugins() Examples
The following are 30
code examples of twisted.plugin.getPlugins().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
twisted.plugin
, or try the search function
.
Example #1
Source File: test_plugin.py From learn_python3_spider with MIT License | 6 votes |
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])
Example #2
Source File: creation.py From imaginary with MIT License | 6 votes |
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)
Example #3
Source File: lore.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
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)
Example #4
Source File: test_plugin.py From python-for-android with Apache License 2.0 | 6 votes |
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])
Example #5
Source File: test_plugin.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
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))
Example #6
Source File: test_plugin.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
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])
Example #7
Source File: test_plugin.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
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])
Example #8
Source File: test_plugin.py From python-for-android with Apache License 2.0 | 6 votes |
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])
Example #9
Source File: test_plugin.py From python-for-android with Apache License 2.0 | 6 votes |
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))
Example #10
Source File: lore.py From python-for-android with Apache License 2.0 | 6 votes |
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)
Example #11
Source File: test_plugin.py From learn_python3_spider with MIT License | 6 votes |
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))
Example #12
Source File: test_plugin.py From learn_python3_spider with MIT License | 6 votes |
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])
Example #13
Source File: axiomatic.py From axiom with MIT License | 5 votes |
def subCommands(): def get(self): yield ('start', None, Start, 'Launch the given Axiom database') if not platform.isWindows(): yield ('stop', None, Stop, 'Stop the server running from the given Axiom database') yield ('status', None, Status, 'Report whether a server is running from the given Axiom database') from axiom import plugins for plg in getPlugins(IAxiomaticCommand, plugins): try: yield (plg.name, None, plg, plg.description) except AttributeError: raise RuntimeError("Maldefined plugin: %r" % (plg,)) return get,
Example #14
Source File: test_plugin.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def _testPlugins(self): plugins = list(plugin.getPlugins(plugin.ITestPlugin2)) self.assertEquals(len(plugins), 2) names = ['AnotherTestPlugin', 'ThirdTestPlugin'] for p in plugins: names.remove(p.__name__) p.test()
Example #15
Source File: trial.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def _loadReporters(self): if self._supportsColor(): default = 'verbose' else: default = 'bwverbose' self.optToQual = {} for p in plugin.getPlugins(itrial.IReporter): qual = "%s.%s" % (p.module, p.klass) self.optToQual[p.longOpt] = qual if p.longOpt == default: self['reporter'] = reflect.namedAny(qual)
Example #16
Source File: test_strcred.py From python-for-android with Apache License 2.0 | 5 votes |
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)
Example #17
Source File: trial.py From python-for-android with Apache License 2.0 | 5 votes |
def _zshReporterAction(): return "(%s)" % (" ".join([p.longOpt for p in plugin.getPlugins(itrial.IReporter)]),)
Example #18
Source File: trial.py From python-for-android with Apache License 2.0 | 5 votes |
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)
Example #19
Source File: zshcomp.py From python-for-android with Apache License 2.0 | 5 votes |
def write(self): """ Write the completion function to the file given to __init__ @return: C{None} """ self.file.write('#compdef %s\n' % (self.cmd_name,)) self.file.write('local _zsh_subcmds_array\n_zsh_subcmds_array=(\n') from twisted import plugin as newplugin plugins = newplugin.getPlugins(self.interface) for p in plugins: self.file.write('"%s:%s"\n' % (p.tapname, p.description)) self.file.write(")\n\n") self.options.__class__.zsh_extras = ['*::subcmd:->subcmd'] gen = ArgumentsGenerator(self.cmd_name, self.options, self.file) gen.write() self.file.write("""if (( CURRENT == 1 )); then _describe "%s" _zsh_subcmds_array && ret=0 fi (( ret )) || return 0 service="$words[1]" case $service in\n""" % (self.subcmdLabel,)) plugins = newplugin.getPlugins(self.interface) for p in plugins: self.file.write(p.tapname + ")\n") gen = ArgumentsGenerator(p.tapname, p.options(), self.file) gen.write() self.file.write(";;\n") self.file.write("*) _message \"don't know how to" \ " complete $service\";;\nesac")
Example #20
Source File: test_plugins.py From python-for-android with Apache License 2.0 | 5 votes |
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]
Example #21
Source File: test_runner.py From python-for-android with Apache License 2.0 | 5 votes |
def tearDown(self): plugin.getPlugins = self.original
Example #22
Source File: strcred.py From python-for-android with Apache License 2.0 | 5 votes |
def findCheckerFactories(): """ Find all objects that implement L{ICheckerFactory}. """ return getPlugins(ICheckerFactory)
Example #23
Source File: reactors.py From python-for-android with Apache License 2.0 | 5 votes |
def getReactorTypes(): """ Return an iterator of L{IReactorInstaller} plugins. """ return getPlugins(IReactorInstaller)
Example #24
Source File: creation.py From imaginary with MIT License | 5 votes |
def listThingTypes(): """ Return a list of C{unicode} strings each of which gives the name of a type which can be created with the create command. """ return sorted([type.type for type in getPlugins(IThingType, imaginary.plugins)])
Example #25
Source File: app.py From python-for-android with Apache License 2.0 | 5 votes |
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)
Example #26
Source File: trial.py From learn_python3_spider with MIT License | 5 votes |
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)
Example #27
Source File: trial.py From learn_python3_spider with MIT License | 5 votes |
def _reporterAction(): return usage.CompleteList([p.longOpt for p in plugin.getPlugins(itrial.IReporter)])
Example #28
Source File: listversions.py From axiom with MIT License | 5 votes |
def getSystemVersions(getPlugins=plugin.getPlugins): """ Collect all the version plugins and extract their L{Version} objects. """ return list(getPlugins(iaxiom.IVersion, plugins))
Example #29
Source File: zshcomp.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def write(self): self.file.write('#compdef mktap\n') self.file.write('_mktap_subcmds=(\n') from twisted import plugin as newplugin from twisted.scripts.mktap import IServiceMaker plugins = newplugin.getPlugins(IServiceMaker) for p in plugins: self.file.write('"%s:%s"\n' % (p.tapname, p.description)) self.file.write(")\n\n") self.options.__class__.zsh_extras = ['*::subcmd:->subcmd'] gen = ArgumentsGenerator(self.cmd_name, self.options, self.file) gen.write() self.file.write("""if (( CURRENT == 1 )); then _describe "tap to build" _mktap_subcmds && ret=0 fi (( ret )) || return 0 service="$words[1]" case $service in\n""") plugins = newplugin.getPlugins(IServiceMaker) for p in plugins: self.file.write(p.tapname + ")\n") gen = ArgumentsGenerator(p.tapname, p.options(), self.file) gen.write() self.file.write(";;\n") self.file.write("""*) _message "don't know how to complete $service";;\nesac""")
Example #30
Source File: test_endpoints.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
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,))