本文整理汇总了Python中yapsy.PluginManager.PluginManager.appendPluginToCategory方法的典型用法代码示例。如果您正苦于以下问题:Python PluginManager.appendPluginToCategory方法的具体用法?Python PluginManager.appendPluginToCategory怎么用?Python PluginManager.appendPluginToCategory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yapsy.PluginManager.PluginManager
的用法示例。
在下文中一共展示了PluginManager.appendPluginToCategory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testTwoStepsLoad
# 需要导入模块: from yapsy.PluginManager import PluginManager [as 别名]
# 或者: from yapsy.PluginManager.PluginManager import appendPluginToCategory [as 别名]
def testTwoStepsLoad(self):
"""
Test loading the plugins in two steps in order to collect more
deltailed informations.
"""
spm = PluginManager(directories_list=[
os.path.join(
os.path.dirname(os.path.abspath(__file__)),"plugins")])
# trigger the first step to look up for plugins
spm.locatePlugins()
# make full use of the "feedback" the loadPlugins can give
# - set-up the callback function that will be called *before*
# loading each plugin
callback_infos = []
def preload_cbk(plugin_info):
callback_infos.append(plugin_info)
# - gather infos about the processed plugins (loaded or not)
loadedPlugins = spm.loadPlugins(callback=preload_cbk)
self.assertEqual(len(loadedPlugins),1)
self.assertEqual(len(callback_infos),1)
self.assertEqual(loadedPlugins[0].error,None)
self.assertEqual(loadedPlugins[0],callback_infos[0])
# 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)
plugin_info = spm.getPluginsOfCategory(sole_category)[0]
# try to remove it and check that is worked
spm.removePluginFromCategory(plugin_info,sole_category)
self.assertEqual(len(spm.getPluginsOfCategory(sole_category)),0)
# now re-add this plugin the to same category
spm.appendPluginToCategory(plugin_info,sole_category)
self.assertEqual(len(spm.getPluginsOfCategory(sole_category)),1)
示例2: testMultipleCategoriesForASamePlugin
# 需要导入模块: from yapsy.PluginManager import PluginManager [as 别名]
# 或者: from yapsy.PluginManager.PluginManager import appendPluginToCategory [as 别名]
def testMultipleCategoriesForASamePlugin(self):
"""
Test that associating a plugin to multiple categories works as expected.
"""
class AnotherPluginIfce(object):
def __init__(self):
pass
def activate(self):
pass
def deactivate(self):
pass
spm = PluginManager(
categories_filter = {
"Default": IPlugin,
"IP": IPlugin,
"Other": AnotherPluginIfce,
},
directories_list=[
os.path.join(
os.path.dirname(os.path.abspath(__file__)),"plugins")])
# load the plugins that may be found
spm.collectPlugins()
# check that the getCategories works
self.assertEqual(len(spm.getCategories()),3)
categories = spm.getCategories()
self.assertTrue("Default" in categories)
# check the getPluginsOfCategory
self.assertEqual(len(spm.getPluginsOfCategory("Default")), 1)
plugin_info = spm.getPluginsOfCategory("Default")[0]
self.assertTrue("Default" in plugin_info.categories)
self.assertTrue("IP" in plugin_info.categories)
self.assertTrue("IP" in categories)
# check the getPluginsOfCategory
self.assertEqual(len(spm.getPluginsOfCategory("IP")),1)
self.assertTrue("Other" in categories)
# check the getPluginsOfCategory
self.assertEqual(len(spm.getPluginsOfCategory("Other")),0)
# try to remove the plugin from one category and check the
# other category
spm.removePluginFromCategory(plugin_info, "Default")
self.assertEqual(len(spm.getPluginsOfCategory("Default")), 0)
self.assertEqual(len(spm.getPluginsOfCategory("IP")), 1)
# now re-add this plugin the to same category
spm.appendPluginToCategory(plugin_info, "Default")
self.assertEqual(len(spm.getPluginsOfCategory("Default")),1)
self.assertEqual(len(spm.getPluginsOfCategory("IP")),1)
示例3: testCategoryManipulation
# 需要导入模块: from yapsy.PluginManager import PluginManager [as 别名]
# 或者: from yapsy.PluginManager.PluginManager import appendPluginToCategory [as 别名]
def testCategoryManipulation(self):
"""
Test querying, removing and adding plugins from/to a category.
"""
spm = PluginManager(directories_list=[
os.path.join(
os.path.dirname(os.path.abspath(__file__)),"plugins")])
# 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)
plugin_info = spm.getPluginsOfCategory(sole_category)[0]
# try to remove it and check that is worked
spm.removePluginFromCategory(plugin_info,sole_category)
self.assertEqual(len(spm.getPluginsOfCategory(sole_category)),0)
# now re-add this plugin the to same category
spm.appendPluginToCategory(plugin_info,sole_category)
self.assertEqual(len(spm.getPluginsOfCategory(sole_category)),1)