I have changed your first test script to work. I am not sure if that is all
you wanted.
import functools
global_commands_dict = {}
def command_method(name):
"""A decorator that creates a Leo command from a method."""
def _wrapper(f):
"""This wrapper is always called with one argument: the wrapped
function."""
@functools.wraps(f)
def inner_wrapper(self, event):
"""Inner wrapper docstring."""
return f(self, event)
global_commands_dict[name] = inner_wrapper
return inner_wrapper
return _wrapper
class Test:
@command_method('get')
def get(self, event):
"""docstring for Test.get."""
g.trace(Test.get.__doc__)
event = g.Bunch(c=c)
Test().get(event)
g.printObj(global_commands_dict, tag='dict')
Executing it write to the console following:
get docstring for Test.get.
dict:
{
get:<function Test.get at 0x7f1b980b8b90>
}
Vitalije
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/leo-editor/433d25e0-874a-4a0b-8ffb-7d5e840f712c%40googlegroups.com.