From 70db97f64e0d6dbdd60f4d6d147d11c5b6b6a204 Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 19 Feb 2020 17:22:37 +0000 Subject: support @utils.export on functions, to export those functions --- src/ModuleManager.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/ModuleManager.py') diff --git a/src/ModuleManager.py b/src/ModuleManager.py index b8dcd107..a43181fe 100644 --- a/src/ModuleManager.py +++ b/src/ModuleManager.py @@ -256,7 +256,13 @@ class ModuleManager(object): module_title = (getattr(module_object, "_name", None) or definition.name.title()) - # @utils.hook() magic + # per-module @export magic + if utils.decorators.has_magic(module_object): + magic = utils.decorators.get_magic(module_object) + for key, value in magic.get_exports(): + context_exports.add(key, value) + + # per-function @hook/@export magic for attribute_name in dir(module_object): attribute = getattr(module_object, attribute_name) if (inspect.ismethod(attribute) and @@ -265,12 +271,8 @@ class ModuleManager(object): for hook, kwargs in magic.get_hooks(): context_events.on(hook)._hook(attribute, kwargs=kwargs) - - # @utils.export() magic - if utils.decorators.has_magic(module_object): - magic = utils.decorators.get_magic(module_object) - for key, value in magic.get_exports(): - context_exports.add(key, value) + for key, value in magic.get_exports(): + context_exports.add(key, attribute) branch, commit = utils.git_commit(bot.directory) -- cgit v1.3.1-10-gc9f91