diff --git a/src/octoprint/plugin/core.py b/src/octoprint/plugin/core.py index 7c9f666ee..c7ce091a6 100644 --- a/src/octoprint/plugin/core.py +++ b/src/octoprint/plugin/core.py @@ -665,7 +665,7 @@ class PluginInfo(object): @property def parsed_metadata(self): - """The plugin metadata parsed from the plugin ``__init__.py``'s AST.""" + """The plugin metadata parsed from the plugin's AST.""" return self._cached_parsed_metadata @property @@ -680,27 +680,8 @@ class PluginInfo(object): def looks_like_plugin(self): """ Returns whether the plugin actually looks like a plugin (has control properties) or not. - - Note that compiled (.pyc) plugins for now will return True here as well, since we - currently cannot easily parse metadata from them. """ - return ( - self.parsed_metadata.get("has_control_properties", False) or self.is_compiled - ) - - @property - def is_compiled(self): - path = self.location - if not path: - return False - - if os.path.isdir(path): - path = os.path.join(self.location, "__init__.py") - - if not os.path.isfile(path): - return False - - return path.endswith(".pyc") + return self.parsed_metadata.get("has_control_properties", False) def _parse_metadata(self): result = {} @@ -1003,11 +984,8 @@ class PluginManager(object): try: if entry.is_dir(): init_py = os.path.join(entry.path, "__init__.py") - init_pyc = os.path.join(entry.path, "__init__.pyc") - if not os.path.isfile(init_py) and not os.path.isfile( - init_pyc - ): + if not os.path.isfile(init_py): # neither does exist, we ignore this continue @@ -1015,8 +993,8 @@ class PluginManager(object): elif entry.is_file(): key, ext = os.path.splitext(entry.name) - if ext not in (".py", ".pyc") or key.startswith("__"): - # neither py nor pyc, or starts with __ (like __init__), we ignore this + if ext not in (".py",) or key.startswith("__"): + # not py, or starts with __ (like __init__), we ignore this continue else: diff --git a/tests/plugin/test_core.py b/tests/plugin/test_core.py index 4b1fdd826..f58fe2f97 100644 --- a/tests/plugin/test_core.py +++ b/tests/plugin/test_core.py @@ -104,10 +104,10 @@ class PluginTestCase(unittest.TestCase): assert "__plugin_implementation__" in str(w[-1].message) def test_plugin_loading(self): - self.assertEqual(9, len(self.plugin_manager.enabled_plugins)) - self.assertEqual(10, len(self.plugin_manager.plugins)) + self.assertEqual(7, len(self.plugin_manager.enabled_plugins)) + self.assertEqual(8, len(self.plugin_manager.plugins)) self.assertEqual(2, len(self.plugin_manager.plugin_hooks)) - self.assertEqual(5, len(self.plugin_manager.plugin_implementations)) + self.assertEqual(4, len(self.plugin_manager.plugin_implementations)) self.assertEqual(3, len(self.plugin_manager.plugin_implementations_by_type)) # hook_plugin @@ -156,7 +156,7 @@ class PluginTestCase(unittest.TestCase): in self.plugin_manager.plugin_implementations_by_type ) self.assertEqual( - 2, + 1, len( self.plugin_manager.plugin_implementations_by_type[ octoprint.plugin.AssetPlugin @@ -180,7 +180,7 @@ class PluginTestCase(unittest.TestCase): ) all_implementations = self.plugin_manager.plugin_implementations - self.assertEqual(5, len(all_implementations)) + self.assertEqual(4, len(all_implementations)) for name, impl in all_implementations.items(): self.assertTrue(name in self.plugin_manager.enabled_plugins) plugin = self.plugin_manager.enabled_plugins[name] @@ -271,7 +271,7 @@ class PluginTestCase(unittest.TestCase): octoprint.plugin.AssetPlugin ) self.assertListEqual( - ["asset_plugin", "asset_plugin_2"], + ["asset_plugin"], list(map(lambda x: x._identifier, implementations)), ) @@ -320,13 +320,12 @@ class PluginTestCase(unittest.TestCase): client2.on_plugin_message.assert_called_once_with(plugin, data, permissions=None) def test_broken_plugin(self): - for key in ("not_a_plugin",): - self.assertTrue(key in self.plugin_manager.plugins) + self.assertTrue("not_a_plugin" in self.plugin_manager.plugins) - plugin = self.plugin_manager.plugins[key] - self.assertFalse(plugin.looks_like_plugin) - self.assertFalse(plugin.loaded) - self.assertFalse(plugin.enabled) + plugin = self.plugin_manager.plugins["not_a_plugin"] + self.assertFalse(plugin.looks_like_plugin) + self.assertFalse(plugin.loaded) + self.assertFalse(plugin.enabled) @ddt.data( (