Hey look ma I can load plugins with a template!

This commit is contained in:
Daniel Dayley 2021-11-02 23:07:44 -06:00
parent c7e86580d4
commit 104f0c0483
2 changed files with 6 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import yaml
import logging import logging
import argparse import argparse
import python-tool import python-tool
##PLUGIN_import importlib
# Import your custom libraries here # Import your custom libraries here
##PLUGIN__plugin_map = {} ##PLUGIN__plugin_map = {}

View File

@ -141,6 +141,11 @@ new_python_tool() {
sed_i "s/.*##PLUGIN_\(.*\)/\1/g" ./"$NAME"/bin/"$NAME" sed_i "s/.*##PLUGIN_\(.*\)/\1/g" ./"$NAME"/bin/"$NAME"
mkdir ./"$NAME"/"$NAME"/plugins mkdir ./"$NAME"/"$NAME"/plugins
touch ./"$NAME"/"$NAME"/plugins/plugin.py touch ./"$NAME"/"$NAME"/plugins/plugin.py
PYTHON_TOOL_SETUP_INSTRUCTIONS+="Set your plugin class by setting the plugin_class variable in bin/$NAME and defining the class in $NAME/plugins/*.py files."
PYTHON_TOOL_WARNINGS+="At least one .py file needs to exist in $NAME/plugins/ for the plugin directory to be packaged for install. 'plugin.py' is provided for this purpose, but can be removed if you have other plugins. The file can be empty."
if [[ "$PYTHON_MODULE" == 'y' ]]; then
PYTHON_TOOL_WARNINGS+="Migrating the plugin-loading logic from bin/$NAME to $NAME/$NAME.py might be a good idea if you want your plugins to be loaded as part of your library."
fi
else : else :
sed_i 's#.*plugins.*##g' ./"$NAME"/setup.py sed_i 's#.*plugins.*##g' ./"$NAME"/setup.py
sed_i "s/.*##PLUGIN_\(.*\)//g" ./"$NAME"/bin/"$NAME" sed_i "s/.*##PLUGIN_\(.*\)//g" ./"$NAME"/bin/"$NAME"