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