From cc0082814b68f95cb56b5bc6dd178ec8dc79223d Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Thu, 22 Feb 2018 14:58:38 -0500 Subject: [PATCH] hooks.ledger_entry: Warn when a template is unconfigured. --- import2ledger/hooks/ledger_entry.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/import2ledger/hooks/ledger_entry.py b/import2ledger/hooks/ledger_entry.py index 97584d9..63984f1 100644 --- a/import2ledger/hooks/ledger_entry.py +++ b/import2ledger/hooks/ledger_entry.py @@ -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='')