Closed simonw closed 2 months ago
Here's the LLM implementation: https://github.com/simonw/llm/blob/d654c9521235a737e59a4f1d77cf4682589123ec/llm/__init__.py#L44-L61
def get_plugins(all=False):
plugins = []
plugin_to_distinfo = dict(pm.list_plugin_distinfo())
for plugin in pm.get_plugins():
if not all and plugin.__name__.startswith("llm.default_plugins."):
continue
plugin_info = {
"name": plugin.__name__,
"hooks": [h.name for h in pm.get_hookcallers(plugin)],
}
distinfo = plugin_to_distinfo.get(plugin)
if distinfo:
plugin_info["version"] = distinfo.version
plugin_info["name"] = (
getattr(distinfo, "name", None) or distinfo.project_name
)
plugins.append(plugin_info)
return plugins
Example output:
./manage.py showplugins
[
{
"name": "django-plugin-blog",
"hooks": [
"installed_apps",
"middleware",
"settings",
"urlpatterns"
],
"version": "0.1"
},
{
"name": "django-plugin-django-header",
"hooks": [
"middleware"
],
"version": "0.1"
}
]
Imitating
showmigrations
. Lists migrations, likedatasette plugins
andllm plugins
do.