As is_actionable and action need to be callables, it's not a simple configuration. We could use entrypoints, similar to pytest:
import pkg_resources
entry_point_group = 'pytest11'
print(f"Plugins in {entry_point_group} entry point group:")
for entry_point in pkg_resources.iter_entry_points(group=entry_point_group):
print(entry_point.name)
It would likely make sense to use an abstract class for the interface so that the entry point. This way we could have multiple types of plugins with the same interface, using isinstance.
We would need
context_menu_name: str
is_actionable(selection: list[Path]) -> bool
action(selection: list[Path]) -> None
.As
is_actionable
andaction
need to be callables, it's not a simple configuration. We could use entrypoints, similar to pytest:It would likely make sense to use an abstract class for the interface so that the entry point. This way we could have multiple types of plugins with the same interface, using isinstance.
Examples
pytest