
This is roughly the smallest diff necessary to move output to a hook. There's a lot of code reorganization that should still happen to bring it better in line with this new structure.
29 lines
860 B
Python
29 lines
860 B
Python
import operator
|
|
|
|
try:
|
|
import enum
|
|
except ImportError:
|
|
import enum34 as enum
|
|
|
|
from .. import dynload
|
|
|
|
HOOK_KINDS = enum.Enum('HOOK_KINDS', [
|
|
# Hooks will run in the order that their KIND appears in this list.
|
|
|
|
# DATA_ADDER hooks should add data to the entry from outside sources like
|
|
# the user's configuration.
|
|
'DATA_ADDER',
|
|
# DATA_MUNGER hooks should add or change data in the entry based on what's
|
|
# already in it.
|
|
'DATA_MUNGER',
|
|
# DATA_FILTER hooks make a decision about whether or not to proceed with
|
|
# processing the entry.
|
|
'DATA_FILTER',
|
|
# OUTPUT hooks run last, sending the data somewhere else.
|
|
'OUTPUT',
|
|
])
|
|
|
|
def load_all():
|
|
hooks = list(dynload.submodule_items_named(__file__, operator.methodcaller('endswith', 'Hook')))
|
|
hooks.sort(key=operator.attrgetter('KIND.value'))
|
|
return hooks
|