hooks.ledger_entry: Warn when a template is unconfigured.
This commit is contained in:
parent
c1baf3c38a
commit
cc0082814b
1 changed files with 6 additions and 1 deletions
|
@ -3,6 +3,7 @@ import datetime
|
||||||
import decimal
|
import decimal
|
||||||
import functools
|
import functools
|
||||||
import io
|
import io
|
||||||
|
import logging
|
||||||
import operator
|
import operator
|
||||||
import re
|
import re
|
||||||
import tokenize
|
import tokenize
|
||||||
|
@ -12,6 +13,8 @@ import babel.numbers
|
||||||
from . import HOOK_KINDS
|
from . import HOOK_KINDS
|
||||||
from .. import errors, strparse
|
from .. import errors, strparse
|
||||||
|
|
||||||
|
logger = logging.getLogger('import2ledger.hooks.ledger_entry')
|
||||||
|
|
||||||
class TokenTransformer:
|
class TokenTransformer:
|
||||||
def __init__(self, source):
|
def __init__(self, source):
|
||||||
try:
|
try:
|
||||||
|
@ -312,6 +315,8 @@ class LedgerEntryHook:
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
have_template = not template.is_empty()
|
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:
|
with self.config.open_output_file() as out_file:
|
||||||
print(template.render(entry_data), file=out_file, end='')
|
print(template.render(entry_data), file=out_file, end='')
|
||||||
|
|
Loading…
Reference in a new issue