3 from Tools.Directories import *
7 components = name.split('.')
8 for comp in components[1:]:
9 mod = getattr(mod, comp)
12 class PluginComponent:
15 self.setPluginPrefix("Plugins.")
17 def setPluginPrefix(self, prefix):
20 def readPluginList(self, runAutostartPlugins=False, runAutoendPlugins=False):
21 """enumerates plugins"""
23 directories = os.listdir(resolveFilename(SCOPE_PLUGINS))
26 path = resolveFilename(SCOPE_PLUGINS, x) + "/"
27 if os.path.exists(path):
28 if fileExists(path + "plugin.py"):
29 plugin = my_import('.'.join(("Plugins", x, "plugin")))
31 if not plugin.__dict__.has_key("Plugins"):
32 print "Plugin %s doesn't have 'Plugin'-call." % (x)
35 print "plugin", plugin
36 plugins = plugin.Plugins()
38 # allow single entry not to be a list
39 if type(plugins) is not list:
43 print "imported plugin %s" % (p.name)
46 self.plugins.setdefault(x, []).append(p)
48 def getPlugins(self, where):
49 """Get list of plugins in a specific category"""
51 if type(where) is not list:
55 for p in self.plugins.get(x, [ ]):
59 plugins = PluginComponent()