hooks.ledger_entry: Warn when a template is unconfigured.

This commit is contained in:
Brett Smith 2018-02-22 14:58:38 -05:00
parent c1baf3c38a
commit cc0082814b

View file

@ -3,6 +3,7 @@ import datetime
import decimal
import functools
import io
import logging
import operator
import re
import tokenize
@ -12,6 +13,8 @@ import babel.numbers
from . import HOOK_KINDS
from .. import errors, strparse
logger = logging.getLogger('import2ledger.hooks.ledger_entry')
class TokenTransformer:
def __init__(self, source):
try:
@ -312,6 +315,8 @@ class LedgerEntryHook:
raise
else:
have_template = not template.is_empty()
if have_template:
if not have_template:
logger.warning("no Ledger template defined as %r", template_key)
else:
with self.config.open_output_file() as out_file:
print(template.render(entry_data), file=out_file, end='')