diff options
Diffstat (limited to 'module')
-rw-r--r-- | module/PluginManager.py | 13 | ||||
-rw-r--r-- | module/api/ConfigApi.py | 4 | ||||
-rw-r--r-- | module/plugins/Addon.py | 4 | ||||
-rw-r--r-- | module/plugins/Base.py | 2 | ||||
-rw-r--r-- | module/remote/pyload.thrift | 2 | ||||
-rw-r--r-- | module/remote/ttypes.py | 6 | ||||
-rw-r--r-- | module/remote/ttypes_debug.py | 2 |
7 files changed, 19 insertions, 14 deletions
diff --git a/module/PluginManager.py b/module/PluginManager.py index f5a3fe31d..c20481e33 100644 --- a/module/PluginManager.py +++ b/module/PluginManager.py @@ -36,7 +36,7 @@ IGNORE = ( 'EasyShareCom', 'FlyshareCz' ) -PluginTuple = namedtuple("PluginTuple", "version re deps user path") +PluginTuple = namedtuple("PluginTuple", "version re deps category user path") class PluginManager: ROOT = "module.plugins." @@ -184,10 +184,10 @@ class PluginManager: else: plugin_re = self.NO_MATCH deps = attrs.get("dependencies", None) + category = attrs.get("category", None) if folder == "addons" else None # create plugin tuple - plugin = PluginTuple(version, plugin_re, deps, bool(home), filename) - + plugin = PluginTuple(version, plugin_re, deps, category, bool(home), filename) # internals have no config if folder == "internal": @@ -285,12 +285,10 @@ class PluginManager: # MultiHoster will overwrite this getPlugin = getPluginClass - def loadAttributes(self, type, name): plugin = self.plugins[type][name] return self.parseAttributes(plugin.path, name, type) - def loadModule(self, type, name): """ Returns loaded module for plugin @@ -396,6 +394,11 @@ class PluginManager: def isPluginType(self, plugin, type): return plugin in self.plugins[type] + def getCategory(self, plugin): + if plugin in self.plugins["addons"]: + return self.plugins["addons"][plugin] or "addon" + + def loadIcons(self): """Loads all icons from plugins, plugin type is not in result, because its not important here. diff --git a/module/api/ConfigApi.py b/module/api/ConfigApi.py index fcc0bdd14..55e0aa49b 100644 --- a/module/api/ConfigApi.py +++ b/module/api/ConfigApi.py @@ -68,7 +68,7 @@ class ConfigApi(ApiComponent): for name, config, values in self.core.config.iterSections(self.user): if not values: continue item = ConfigInfo(name, config.name, config.description, - self.core.pluginManager.isPluginType(name, "addons"), + self.core.pluginManager.getCategory(name), self.core.pluginManager.isUserPlugin(name), values.get("activated", False)) data.append(item) @@ -84,7 +84,7 @@ class ConfigApi(ApiComponent): """ # TODO: filter user_context / addons when not allowed return [ConfigInfo(name, config.name, config.description, - self.core.pluginManager.isPluginType(name, "addons"), + self.core.pluginManager.getCategory(name), self.core.pluginManager.isUserPlugin(name)) for name, config, values in self.core.config.iterSections(self.user)] diff --git a/module/plugins/Addon.py b/module/plugins/Addon.py index 8b4430672..ff9c57bef 100644 --- a/module/plugins/Addon.py +++ b/module/plugins/Addon.py @@ -145,7 +145,6 @@ class Addon(Base): self.cb = self.core.scheduler.addJob(self.interval, self._periodical, threaded=False) - def __repr__(self): return "<Addon %s>" % self.__name__ @@ -153,6 +152,9 @@ class Addon(Base): """ checks if addon is activated""" return True if self.__internal__ else self.getConfig("activated") + def getCategory(self): + return self.core.pluginManager.getCategory(self.__name__) + def init(self): pass diff --git a/module/plugins/Base.py b/module/plugins/Base.py index 9bfeaba4b..cc327f861 100644 --- a/module/plugins/Base.py +++ b/module/plugins/Base.py @@ -58,7 +58,7 @@ class Base(object): __description__ = """""" #: List of needed modules __dependencies__ = tuple() - #: Used to assign a category to addon plugins + #: Used to assign a category for addon plugins __category__ = "" #: Tags to categorize the plugin, see documentation for further info __tags__ = tuple() diff --git a/module/remote/pyload.thrift b/module/remote/pyload.thrift index 6a77bdc1d..7eadd54e6 100644 --- a/module/remote/pyload.thrift +++ b/module/remote/pyload.thrift @@ -250,7 +250,7 @@ struct ConfigInfo { 1: string name 2: string label, 3: string description, - 4: bool addon, + 4: string category, 5: bool user_context, 6: optional bool activated, } diff --git a/module/remote/ttypes.py b/module/remote/ttypes.py index 1592829a3..1f91403d5 100644 --- a/module/remote/ttypes.py +++ b/module/remote/ttypes.py @@ -139,13 +139,13 @@ class ConfigHolder(BaseObject): self.handler = handler class ConfigInfo(BaseObject): - __slots__ = ['name', 'label', 'description', 'addon', 'user_context', 'activated'] + __slots__ = ['name', 'label', 'description', 'category', 'user_context', 'activated'] - def __init__(self, name=None, label=None, description=None, addon=None, user_context=None, activated=None): + def __init__(self, name=None, label=None, description=None, category=None, user_context=None, activated=None): self.name = name self.label = label self.description = description - self.addon = addon + self.category = category self.user_context = user_context self.activated = activated diff --git a/module/remote/ttypes_debug.py b/module/remote/ttypes_debug.py index 84b56e55d..f7f02b127 100644 --- a/module/remote/ttypes_debug.py +++ b/module/remote/ttypes_debug.py @@ -10,7 +10,7 @@ classes = { 'AddonInfo' : [basestring, basestring, basestring], 'AddonService' : [basestring, basestring, (list, basestring), (None, int)], 'ConfigHolder' : [basestring, basestring, basestring, basestring, (list, ConfigItem), (None, (list, AddonInfo)), (None, (list, InteractionTask))], - 'ConfigInfo' : [basestring, basestring, basestring, bool, bool, (None, bool)], + 'ConfigInfo' : [basestring, basestring, basestring, basestring, bool, (None, bool)], 'ConfigItem' : [basestring, basestring, basestring, basestring, (None, basestring), basestring], 'DownloadInfo' : [basestring, basestring, basestring, int, basestring, basestring], 'DownloadProgress' : [int, int, int, int], |