Files @ b41a7a99af17
Branch filter:

Location: NPO-Accounting/import2ledger/import2ledger/hooks/filter_by_date.py

Brett Smith
hooks: Filter entries by setting entry_data['_hook_cancel'] to True.

The current method only works for plain dicts and other simple mappings.
Mapping that may still contain items after .clear(), like ChainMap, can't
rely on the old method.
class FilterByDateHook:
    def __init__(self, config):
        self.config = config

    def run(self, entry_data):
        try:
            date = entry_data['date']
        except KeyError:
            pass
        else:
            if not self.config.date_in_want_range(date):
                entry_data['_hook_cancel'] = True