From 104f0c04834d8d9ac48d3d35c6e4de8e8b7168a5 Mon Sep 17 00:00:00 2001 From: Daniel Dayley Date: Tue, 2 Nov 2021 23:07:44 -0600 Subject: [PATCH] Hey look ma I can load plugins with a template! --- bin/python-tool | 1 + new_python_tool.sh | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/bin/python-tool b/bin/python-tool index 185a3b3..b0aae9d 100644 --- a/bin/python-tool +++ b/bin/python-tool @@ -6,6 +6,7 @@ import yaml import logging import argparse import python-tool +##PLUGIN_import importlib # Import your custom libraries here ##PLUGIN__plugin_map = {} diff --git a/new_python_tool.sh b/new_python_tool.sh index 7e1a30f..425a8fd 100755 --- a/new_python_tool.sh +++ b/new_python_tool.sh @@ -141,6 +141,11 @@ new_python_tool() { sed_i "s/.*##PLUGIN_\(.*\)/\1/g" ./"$NAME"/bin/"$NAME" mkdir ./"$NAME"/"$NAME"/plugins 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 : sed_i 's#.*plugins.*##g' ./"$NAME"/setup.py sed_i "s/.*##PLUGIN_\(.*\)//g" ./"$NAME"/bin/"$NAME"