+
+ def addPlugin(self, plugin):
+ self.pluginList.append(plugin)
+ for x in plugin.where:
+ self.plugins.setdefault(x, []).append(plugin)
+ if x == PluginDescriptor.WHERE_AUTOSTART:
+ plugin(reason=0)
+
+ def removePlugin(self, plugin):
+ self.pluginList.remove(plugin)
+ for x in plugin.where:
+ self.plugins[x].remove(plugin)
+ if x == PluginDescriptor.WHERE_AUTOSTART:
+ plugin(reason=1)
+
+ def readPluginList(self, directory, modules = [], depth = 1):
+ """enumerates plugins"""
+
+ directories = os.listdir(directory)
+
+ for x in directories:
+ path = directory + x + "/"
+ if os.path.isdir(path):
+ if fileExists(path + "plugin.py"):
+ plugin = my_import('.'.join(["Plugins"] + modules + [x, "plugin"]))
+
+ if not plugin.__dict__.has_key("Plugins"):
+ print "Plugin %s doesn't have 'Plugin'-call." % (x)
+ continue
+
+ plugins = plugin.Plugins()
+
+ # allow single entry not to be a list
+ if type(plugins) is not list:
+ plugins = [ plugins ]
+
+ for p in plugins:
+ p.updateIcon(path)
+ self.addPlugin(p);
+ else:
+ self.readPluginList(path, modules + [x], depth - 1)