From 28fc7d74f49d3f0ccd8d6095e2b0b4aabf11a99d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 30 Sep 2015 13:33:25 +0200 Subject: [PATCH] Made plugin marking in PluginManager more flexible Now supports arbitrary markers for plugins. Also added a method to check if a plugin was marked with a specified marker. --- src/octoprint/plugin/core.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/octoprint/plugin/core.py b/src/octoprint/plugin/core.py index 41a36883..0dee798c 100644 --- a/src/octoprint/plugin/core.py +++ b/src/octoprint/plugin/core.py @@ -686,15 +686,24 @@ class PluginManager(object): hooks=sum(map(lambda x: len(x), self.plugin_hooks.values())) )) - def mark_plugin(self, name, uninstalled=None): + def mark_plugin(self, name, **kwargs): if not name in self.plugins: - self.logger.warn("Trying to mark an unknown plugin {name}".format(**locals())) + self.logger.debug("Trying to mark an unknown plugin {name}".format(**locals())) - if uninstalled is not None: - if uninstalled and not name in self.marked_plugins["uninstalled"]: - self.marked_plugins["uninstalled"].append(name) - elif not uninstalled and name in self.marked_plugins["uninstalled"]: - self.marked_plugins["uninstalled"].remove(name) + for key, value in kwargs.items(): + if value is None: + continue + + if value and not name in self.marked_plugins[key]: + self.marked_plugins[key].append(name) + elif not value and name in self.marked_plugins[key]: + self.marked_plugins[key].remove(name) + + def is_plugin_marked(self, name, key): + if not name in self.plugins: + return False + + return name in self.marked_plugins[key] def load_plugin(self, name, plugin=None, startup=False, initialize_implementation=True): if not name in self.plugins: