devsup.db: add initHook() dectorator
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import traceback
|
||||
from functools import wraps
|
||||
from collections import defaultdict
|
||||
|
||||
try:
|
||||
@ -11,6 +12,7 @@ except ImportError:
|
||||
__all__ = [
|
||||
"hooknames",
|
||||
"addHook",
|
||||
"initHook",
|
||||
"debugHooks",
|
||||
]
|
||||
|
||||
@ -38,6 +40,18 @@ def addHook(state, func):
|
||||
_hooktable[sid].append(func)
|
||||
|
||||
|
||||
def initHook(state):
|
||||
"""Decorator for initHook functions
|
||||
|
||||
@initHook("AfterIocRunning")
|
||||
def myfn():
|
||||
# do stuff
|
||||
"""
|
||||
def _add(fn):
|
||||
addHook(state, fn)
|
||||
return fn
|
||||
return _add
|
||||
|
||||
def debugHooks():
|
||||
"""Install debugging print to hooks
|
||||
"""
|
||||
|
Reference in New Issue
Block a user