def test_setPluginLocator_with_plugin_info_class(self):
		class SpecificLocator(IPluginLocator):

			def getPluginInfoClass(self):
				return self.picls

			def setPluginInfoClass(self,picls):
				self.picls = picls
			
		class SpecificPluginInfo(PluginInfo):
			pass
		pm = PluginManager()
		pm.setPluginLocator(SpecificLocator(),picls=SpecificPluginInfo)
		self.assertEqual(SpecificPluginInfo,pm.getPluginInfoClass())
Exemple #2
0
    def test_setPluginLocator_with_plugin_info_class(self):
        class SpecificLocator(IPluginLocator):
            def getPluginInfoClass(self):
                return self.picls

            def setPluginInfoClass(self, picls):
                self.picls = picls

        class SpecificPluginInfo(PluginInfo):
            pass

        pm = PluginManager()
        pm.setPluginLocator(SpecificLocator(), picls=SpecificPluginInfo)
        self.assertEqual(SpecificPluginInfo, pm.getPluginInfoClass())
	def testNonRecursivePluginlocationNotFound(self):
		"""
		Test detection of plugins when the detection is non recursive.
		Here we test that it cannot look into subdirectories of the
		test directory.
		"""
		pluginLocator = PluginFileLocator()
		pluginLocator.setPluginPlaces([
					os.path.dirname(os.path.abspath(__file__))])
		pluginLocator.disableRecursiveScan()
		spm = PluginManager()
		spm.setPluginLocator(pluginLocator)
		# load the plugins that may be found
		spm.collectPlugins()
		# check that the getCategories works
		self.assertEqual(len(spm.getCategories()),1)
		sole_category = spm.getCategories()[0]
		# check the getPluginsOfCategory
		self.assertEqual(len(spm.getPluginsOfCategory(sole_category)),0)
    def testNonRecursivePluginlocationNotFound(self):
        """
		Test detection of plugins when the detection is non recursive.
		Here we test that it cannot look into subdirectories of the
		test directory.
		"""
        pluginLocator = PluginFileLocator()
        pluginLocator.setPluginPlaces(
            [os.path.dirname(os.path.abspath(__file__))])
        pluginLocator.disableRecursiveScan()
        spm = PluginManager()
        spm.setPluginLocator(pluginLocator)
        # load the plugins that may be found
        spm.collectPlugins()
        # check that the getCategories works
        self.assertEqual(len(spm.getCategories()), 1)
        sole_category = spm.getCategories()[0]
        # check the getPluginsOfCategory
        self.assertEqual(len(spm.getPluginsOfCategory(sole_category)), 0)
Exemple #5
0
    def testDisablingRecursivePluginLocationAllowsFindingTopLevelPlugins(self):
        """
		Test detection of plugins when the detection is non
		recursive. Here we test that if we give test/plugin as the
		directory to scan it can find the plugin.
		"""
        pluginLocator = PluginFileLocator()
        pluginLocator.setPluginPlaces([
            os.path.join(os.path.dirname(os.path.abspath(__file__)), "plugins")
        ])
        pluginLocator.disableRecursiveScan()
        spm = PluginManager()
        spm.setPluginLocator(pluginLocator)
        # load the plugins that may be found
        spm.collectPlugins()
        # check that the getCategories works
        self.assertEqual(len(spm.getCategories()), 1)
        sole_category = spm.getCategories()[0]
        # check the getPluginsOfCategory
        self.assertEqual(len(spm.getPluginsOfCategory(sole_category)), 1)
Exemple #6
0
	def testDisablingRecursivePluginLocationAllowsFindingTopLevelPlugins(self):
		"""
		Test detection of plugins when the detection is non
		recursive. Here we test that if we give test/plugin as the
		directory to scan it can find the plugin.
		"""
		pluginLocator = PluginFileLocator()
		pluginLocator.setPluginPlaces([
				os.path.join(
					os.path.dirname(os.path.abspath(__file__)),"plugins")])
		pluginLocator.disableRecursiveScan()
		spm = PluginManager()
		spm.setPluginLocator(pluginLocator)
		# load the plugins that may be found
		spm.collectPlugins()
		# check that the getCategories works
		self.assertEqual(len(spm.getCategories()),1)
		sole_category = spm.getCategories()[0]
		# check the getPluginsOfCategory
		self.assertEqual(len(spm.getPluginsOfCategory(sole_category)),1)
Exemple #7
0
from yapsy.PluginManager import PluginManager
import logging

logging.basicConfig(level=logging.DEBUG)
# Build the manager
simplePluginManager = PluginManager()
# Tell it the default place(s) where to find plugins
simplePluginManager.setPluginPlaces(["plugins"])
# Load all plugins
simplePluginManager.setPluginLocator()
simplePluginManager.collectPlugins()

print("start")
# Activate all loaded plugins
print(simplePluginManager.getAllPlugins())
for pluginInfo in simplePluginManager.getAllPlugins():
    print(pluginInfo)
    simplePluginManager.activatePluginByName(pluginInfo.name)
    pluginInfo.plugin_object.speak()