3 from Tools.Directories import *
4 from Plugins.Plugin import PluginDescriptor
8 components = name.split('.')
9 for comp in components[1:]:
10 mod = getattr(mod, comp)
13 class PluginComponent:
17 self.setPluginPrefix("Plugins.")
19 def setPluginPrefix(self, prefix):
22 def addPlugin(self, plugin):
23 self.pluginList.append(plugin)
24 for x in plugin.where:
25 self.plugins.setdefault(x, []).append(plugin)
26 if x == PluginDescriptor.WHERE_AUTOSTART:
29 def removePlugin(self, plugin):
30 self.pluginList.remove(plugin)
31 for x in plugin.where:
32 self.plugins[x].remove(plugin)
33 if x == PluginDescriptor.WHERE_AUTOSTART:
36 def readPluginList(self):
37 """enumerates plugins"""
39 directories = os.listdir(resolveFilename(SCOPE_PLUGINS))
42 path = resolveFilename(SCOPE_PLUGINS, x) + "/"
43 if os.path.exists(path):
44 if fileExists(path + "plugin.py"):
45 plugin = my_import('.'.join(("Plugins", x, "plugin")))
47 if not plugin.__dict__.has_key("Plugins"):
48 print "Plugin %s doesn't have 'Plugin'-call." % (x)
51 print "plugin", plugin
52 plugins = plugin.Plugins()
54 # allow single entry not to be a list
55 if type(plugins) is not list:
61 def getPlugins(self, where):
62 """Get list of plugins in a specific category"""
64 if type(where) is not list:
68 for p in self.plugins.get(x, [ ]):
73 for p in self.pluginList[:]:
76 plugins = PluginComponent()