Closed antirotor closed 5 years ago
Whop, you are fast. Commented here.
Let's continue implementation-specifics here.
So now basic filter example looks like this:
def my_plugin_filter(plugins):
for name, plugin in list(plugins.items()):
if plugin.__name__ == "MyFilteredPlugin":
del plugins[name]
pass
Is like this because in python 3, you cannot delete from dictionary while iterating over it.
@antirotor Thanks for this, would you mind if I made a few tweaks to your implementation?
Let me know what you think about these changes, and whether they still apply to your usecase.
Seems ok for me, looks cleaner. I have no problem with those changes.
Great, then we're all set. :) Thanks @antirotor
This implements #343
Adding ability to filter plugins and modify plugins during discovery. This is using same
register_*
logic as already existing api.Adding filter function:
Filter function must return tuple
(plugin, filtered)
->(class, bool)
Plugin is plugin class processed by filter function, filtered is bool indicating wheter plugin should be filtered out or not.So simple filter function can look like:
This can also modify plugin:
This PR adds: