Hook factorisation ; add new hooks : default (same comportement has previous version) and one hook before any parsing
When calling a hook, passed parameters change according to associated data variable
This commit is contained in:
parent
9ec07790ef
commit
7e20368c10
8 changed files with 109 additions and 63 deletions
10
importer.py
10
importer.py
|
|
@ -21,6 +21,8 @@ from importlib.abc import SourceLoader
|
|||
import imp
|
||||
import os
|
||||
import sys
|
||||
|
||||
from hooks import Hook
|
||||
import xmlparser
|
||||
|
||||
class ModuleFinder(Finder):
|
||||
|
|
@ -206,6 +208,14 @@ def register_hooks(module, context, prompt):
|
|||
for msg in module.CONF.getNodes("message"):
|
||||
context.hooks.register_hook(module, msg)
|
||||
|
||||
# Register legacy hooks
|
||||
if hasattr(module, "parseanswer"):
|
||||
context.hooks.add_hook(context.hooks.cmd_default, Hook(module.parseanswer))
|
||||
if hasattr(module, "parseask"):
|
||||
context.hooks.add_hook(context.hooks.ask_default, Hook(module.parseask))
|
||||
if hasattr(module, "parselisten"):
|
||||
context.hooks.add_hook(context.hooks.ask_default, Hook(module.parselisten))
|
||||
|
||||
##########################
|
||||
# #
|
||||
# Module functions #
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue