Support custom plugin locations and arbitrary plugin modules #160
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allow users to write their own plugins without needing to download the project repo. They can install
did
and use the config file to point to their custom plugins. This also makes it easier to share plugins outside of the project itself.PYTHONPATH
) as well as arbitrary places on the file system.custom_plugins
option to thegeneral
section of the config. Users can add a space or comma separated list of directories where custom plugins reside, and they'll automatically get loaded if the directories are valid python2 packages (include__init__.py
files).StatsGroup
subclasses register themselves. This removes the need to scan modules individually and allows plugins to be defined at any level in a package hierarchy.This PR introduces no new dependencies, but it does use
importlib
, which only comes installed with python 2.7 and beyond. It's available in pypi for python 2.6. The new loader code is python2/3 compatible.Example config:
Example file (thing.py) in ~/did/custom_plugins:
Example help: