aboutsummaryrefslogtreecommitdiff
path: root/src/ModuleManager.py
diff options
context:
space:
mode:
authorGravatar jesopo2020-02-19 17:22:37 +0000
committerGravatar jesopo2020-02-19 17:22:37 +0000
commit70db97f64e0d6dbdd60f4d6d147d11c5b6b6a204 (patch)
tree353f18c924b00683d7565dd6699360e4e0bc4d78 /src/ModuleManager.py
parentshow when a badge was updated, not added, by "!badge add" (diff)
signature
support @utils.export on functions, to export those functions
Diffstat (limited to 'src/ModuleManager.py')
-rw-r--r--src/ModuleManager.py16
1 files changed, 9 insertions, 7 deletions
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)