From 86734076e0129bdc4fbc941e01d955685c27b132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 30 Jan 2015 18:04:15 +0100 Subject: [PATCH] Fixed a bug which caused self.implementations to be able to return None instead of [] if no implementations were provided by a plugin --- src/octoprint/plugin/core.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/octoprint/plugin/core.py b/src/octoprint/plugin/core.py index a84a96b1..2f57c437 100644 --- a/src/octoprint/plugin/core.py +++ b/src/octoprint/plugin/core.py @@ -72,7 +72,7 @@ class PluginInfo(object): @property def name(self): - return self._get_instance_attribute(self.__class__.attr_name, default=(self._name, self.key)) + return self._get_instance_attribute(self.__class__.attr_name, defaults=(self._name, self.key)) @property def description(self): @@ -114,15 +114,13 @@ class PluginInfo(object): def init(self): return self._get_instance_attribute(self.__class__.attr_init, default=lambda: True) - def _get_instance_attribute(self, attr, default=None): + def _get_instance_attribute(self, attr, default=None, defaults=None): if not hasattr(self.instance, attr): - if isinstance(default, (tuple, list)): - for value in default: + if defaults is not None: + for value in defaults: if value is not None: return value - return None - else: - return default + return default return getattr(self.instance, attr)