示例#1
0
def PluginComponent_addPlugin(self, plugin, *args, **kwargs):
	if len(plugin.where) > 1:
		print("[PluginSort] Splitting %s up in individual entries (%s)" % (plugin.name, repr(plugin.where)))
		for x in plugin.where:
			pd = PluginDescriptor(name=plugin.name, where=[x], description=plugin.description, icon=plugin.icon, fnc=plugin.__call__, wakeupfnc=plugin.wakeupfnc, needsRestart=plugin.needsRestart, internal=plugin.internal, weight=plugin.weight)

			newWeight = pluginWeights.get(pd)
			if DEBUG: print("[PluginSort] Setting weight of %s from %d to %d" % (pd.name, pd.weight, newWeight))
			pd.weight = newWeight
			PluginComponent.pluginSort_baseAddPlugin(self, pd, *args, **kwargs)

		# installedPluginList is a list of original descriptors, but we changed it to be a copy, not a reference. so keep it up to date
		if self.firstRun:
			self.installedPluginList.append(plugin)
			if DEBUG: print("[PluginSort] Adding %s to list of installed plugins (%s, %s)." % (plugin.name, plugin.path, repr(plugin.where)))
		return

	newWeight = pluginWeights.get(plugin)
	if DEBUG: print("[PluginSort] Setting weight of %s from %d to %d" % (plugin.name, plugin.weight, newWeight))
	plugin.weight = newWeight
	PluginComponent.pluginSort_baseAddPlugin(self, plugin, *args, **kwargs)

	if self.firstRun:
		if DEBUG: print("[PluginSort] Adding %s to list of installed plugins (%s, %s)." % (plugin.name, plugin.path, repr(plugin.where)))
		self.installedPluginList.append(plugin)
示例#2
0
def PluginComponent_addPlugin(self, plugin, *args, **kwargs):
	if len(plugin.where) > 1:
		print("[PluginSort] Splitting %s up in individual entries (%s)" % (plugin.name, repr(plugin.where)))
		for x in plugin.where:
			pd = PluginDescriptor(name=plugin.name, where=[x], description=plugin.description, icon=plugin.icon, fnc=plugin.__call__, wakeupfnc=plugin.wakeupfnc, needsRestart=plugin.needsRestart, internal=plugin.internal, weight=plugin.weight)
			pd.path = plugin.path

			newWeight = pluginWeights.get(pd)
			if DEBUG: print("[PluginSort] Setting weight of %s from %d to %d" % (pd.name, pd.weight, newWeight))
			pd.weight = newWeight
			PluginComponent.pluginSort_baseAddPlugin(self, pd, *args, **kwargs)

		# installedPluginList is a list of original descriptors, but we changed it to be a copy, not a reference. so keep it up to date
		if self.firstRun:
			self.installedPluginList.append(plugin)
			if DEBUG: print("[PluginSort] Adding %s to list of installed plugins (%s, %s)." % (plugin.name, plugin.path, repr(plugin.where)))
		return

	newWeight = pluginWeights.get(plugin)
	if DEBUG: print("[PluginSort] Setting weight of %s from %d to %d" % (plugin.name, plugin.weight, newWeight))
	plugin.weight = newWeight
	PluginComponent.pluginSort_baseAddPlugin(self, plugin, *args, **kwargs)

	if self.firstRun:
		if DEBUG: print("[PluginSort] Adding %s to list of installed plugins (%s, %s)." % (plugin.name, plugin.path, repr(plugin.where)))
		self.installedPluginList.append(plugin)
示例#3
0
	def PluginComponent_removePlugin(self, plugin, *args, **kwargs):
		print("[PluginSort] Supposed to remove plugin: %s (%s, %s)." % (plugin.name, plugin.path, repr(plugin.where)))
		try:
			PluginComponent.pluginSort_baseRemovePlugin(self, plugin, *args, **kwargs)
		except ValueError as ve:
			revMap = reverse(WHEREMAP)
			print("-"*40)
			print("-"*40)
			print("-"*40)
			print("[PluginSort] pluginList: %s" % (repr([(x.name, x.path, repr([revMap[y] for y in x.where])) for x in self.pluginList]),))
			for w in plugin.where:
				print("[PluginSort] plugins[%s]: %s" % (revMap[w], repr([(x.name, x.path, repr([revMap[y] for y in x.where])) for x in self.plugins[w]])))
示例#4
0
	def PluginComponent_removePlugin(self, plugin, *args, **kwargs):
		print("[PluginSort] Supposed to remove plugin: %s (%s, %s)." % (plugin.name, plugin.path, repr(plugin.where)))
		try:
			PluginComponent.pluginSort_baseRemovePlugin(self, plugin, *args, **kwargs)
		except ValueError as ve:
			revMap = reverse(WHEREMAP)
			print("-"*40)
			print("-"*40)
			print("-"*40)
			print("[PluginSort] pluginList: %s" % (repr([(x.name, x.path, repr([revMap[y] for y in x.where])) for x in self.pluginList]),))
			for w in plugin.where:
				print("[PluginSort] plugins[%s]: %s" % (revMap[w], repr([(x.name, x.path, repr([revMap[y] for y in x.where])) for x in self.plugins[w]])))
示例#5
0
def PluginComponent_getPlugins(self, where):
	if not isinstance(where, list):
		where = [ where ]

	res = []
	if PluginDescriptor.WHERE_EXTENSIONSMENU in where:
		hide = config.plugins.pluginhider.hideextensions.value
		res.extend((x for x in self.plugins.get(PluginDescriptor.WHERE_EXTENSIONSMENU, []) if x.name not in hide))
		where.remove(PluginDescriptor.WHERE_EXTENSIONSMENU)

	if PluginDescriptor.WHERE_PLUGINMENU in where:
		hide = config.plugins.pluginhider.hideplugins.value
		res.extend((x for x in self.plugins.get(PluginDescriptor.WHERE_PLUGINMENU, []) if x.name not in hide))
		where.remove(PluginDescriptor.WHERE_PLUGINMENU)

	if PluginDescriptor.WHERE_EVENTINFO in where:
		hide = config.plugins.pluginhider.hideeventinfo.value
		res.extend((x for x in self.plugins.get(PluginDescriptor.WHERE_EVENTINFO , []) if x.name not in hide))
		where.remove(PluginDescriptor.WHERE_EVENTINFO)

	if where:
		res.extend(PluginComponent.pluginHider_baseGetPlugins(self, where))
	if hasPluginWeight:
		res.sort(key=attrgetter('weight'))
	return res
示例#6
0
def PluginComponent_getPlugins(self, where):
    if not isinstance(where, list):
        where = [where]

    res = []
    if PluginDescriptor.WHERE_EXTENSIONSMENU in where:
        hide = config.plugins.pluginhider.hideextensions.value
        res.extend((x for x in self.plugins.get(
            PluginDescriptor.WHERE_EXTENSIONSMENU, []) if x.name not in hide))
        where.remove(PluginDescriptor.WHERE_EXTENSIONSMENU)

    if PluginDescriptor.WHERE_PLUGINMENU in where:
        hide = config.plugins.pluginhider.hideplugins.value
        res.extend(
            (x for x in self.plugins.get(PluginDescriptor.WHERE_PLUGINMENU, [])
             if x.name not in hide))
        where.remove(PluginDescriptor.WHERE_PLUGINMENU)

    if PluginDescriptor.WHERE_EVENTINFO in where:
        hide = config.plugins.pluginhider.hideeventinfo.value
        res.extend(
            (x for x in self.plugins.get(PluginDescriptor.WHERE_EVENTINFO, [])
             if x.name not in hide))
        where.remove(PluginDescriptor.WHERE_EVENTINFO)

    if where:
        res.extend(PluginComponent.pluginHider_baseGetPlugins(self, where))
    if hasPluginWeight:
        res.sort(key=attrgetter('weight'))
    return res