diff options
| author | 2018-09-02 19:54:45 +0100 | |
|---|---|---|
| committer | 2018-09-02 19:54:45 +0100 | |
| commit | 8c6ab17e579cf8f4e510ec324fc98b010ff01cb0 (patch) | |
| tree | c0437f76bbe9dea31f5f4599450ed5b492eedcd6 /ModuleManager.py | |
| parent | IRCLogging -> Logging (diff) | |
| signature | ||
give an Exports object (actually, ExportsContex object) to each module, to
facilitate things like !set and !channelset without using the events system
Diffstat (limited to 'ModuleManager.py')
| -rw-r--r-- | ModuleManager.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/ModuleManager.py b/ModuleManager.py index a05918cb..56ad2323 100644 --- a/ModuleManager.py +++ b/ModuleManager.py @@ -1,9 +1,10 @@ import glob, imp, inspect, os, sys, uuid class ModuleManager(object): - def __init__(self, bot, events, directory="modules"): + def __init__(self, bot, events, exports, directory="modules"): self.bot = bot self.events = events + self.exports = exports self.directory = directory self.modules = {} self.waiting_requirement = {} @@ -49,12 +50,12 @@ class ModuleManager(object): if not inspect.isclass(module.Module): raise ImportError("module '%s' has a Module attribute but it is not a class.") - event_context = str(uuid.uuid4()) + context = str(uuid.uuid4()) module_object = module.Module(self.bot, self.events.new_context( - event_context)) + context), self.exports.new_context(context)) if not hasattr(module_object, "_name"): module_object._name = name.title() - module_object._event_context = event_context + module_object._context = context module_object._import_name = name assert not module_object._name in self.modules, ( @@ -87,8 +88,9 @@ class ModuleManager(object): module = self.modules[name] del self.modules[name] - event_context = module._event_context - self.events.purge_context(event_context) + context = module._context + self.events.purge_context(context) + self.exports.purge_context(context) del sys.modules[name] references = sys.getrefcount(module) |
