from inspect import signature from configspec import * from shepherd import PluginInterface """ Plugin to test basic registration calls. """ interface = PluginInterface() confspec = ConfigSpecification() confspec.add_spec("spec1", StringSpec()) interface.register_confspec(confspec) def my_interface_function(): return 42 interface.register_function(my_interface_function) def basic_attachment(): return "basic attachment" def attachment_with_args(arg_a, arg_b): return F"attachment with args: {arg_a}, {arg_b}" def attachment_with_fancy_args(arg_a, arg_b, arg_c=True): return F"attachment with fancy args: {arg_a}, {arg_b}, {arg_c}" interface.register_hook("basic_hook") interface.register_hook("hook_with_args", ("arg_a", "arg_b")) interface.register_hook("hook_with_fancy_args", signature(lambda arg_a, arg_b, arg_c=True: None)) interface.register_attachment(basic_attachment, "basic_hook") interface.register_attachment(attachment_with_args, "simpletestplugin.hook_with_args") interface.register_attachment(attachment_with_fancy_args, "hook_with_fancy_args")