import2ledger/import2ledger/hooks/__init__.py
Brett Smith 76f2707aac hooks.ledger_entry: New hook to output Ledger entries.
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.
2017-12-31 12:35:20 -05:00

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