Skip to content
This repository has been archived by the owner on Nov 9, 2024. It is now read-only.

Commit

Permalink
Added enable method to plugin class and enable_all_plugins method to …
Browse files Browse the repository at this point in the history
…pluginloader
  • Loading branch information
nint8835 committed Mar 10, 2017
1 parent d796d4a commit 36a4db7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions jigsaw/Plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ def __init__(self, manifest: dict, *args) -> None:
"""
self.manifest = manifest

def enable(self) -> None:
"""
Handles the setup of a plugin on enable
"""
pass

def disable(self) -> None:
"""
Handles cleaning up before disabling/unloading a plugin
Expand Down
7 changes: 7 additions & 0 deletions jigsaw/PluginLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ def disable_all_plugins(self) -> None:
for plugin in self._plugins:
self._plugins[plugin].disable()

def enable_all_plugins(self) -> None:
"""
Calls the enable method on all initialized plugins
"""
for plugin in self._plugins:
self._plugins[plugin].enable()

def reload_plugin(self, name: str, *args) -> None:
"""
Reloads a given plugin
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="Jigsaw",
version="2.1.4",
version="2.2.0",
packages=["jigsaw", ],
license="MIT",
description="A plugin framework for Python3.6+",
Expand Down
7 changes: 7 additions & 0 deletions tests/test_jigsaw.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ def test_disable_all_plugins():
j.disable_all_plugins()


def test_enable_all_plugins():
j = jigsaw.PluginLoader(os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "plugins")))
j.load_manifests()
j.load_plugins()
j.enable_all_plugins()


def test_reload_all_plugins():
j = jigsaw.PluginLoader(os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "plugins")))
j.load_manifests()
Expand Down

0 comments on commit 36a4db7

Please sign in to comment.