diff --git a/calendar/teachingdates/app.py b/calendar/teachingdates/app.py index 1b2bb7b..4d448e2 100644 --- a/calendar/teachingdates/app.py +++ b/calendar/teachingdates/app.py @@ -3,6 +3,8 @@ import pathlib import sys +from jinja2 import TemplateNotFound + import teachingdates.calendars as calendars import teachingdates.config as configuration from teachingdates import PROG @@ -24,21 +26,20 @@ if args.debug: print("Calendar: {cal}".format(cal=cal.calendar())) print("Lectures: {lec}".format(lec=cal.lecture_dates())) - for c in cal.render(args.style, args.format): - print(c) + print(cal.render(args.style, args.format)) except configuration.ConfigurationError as e: print("{prog}: error: failed to load configuration from " - "'{file}'.".format(prog=PROG, file=e)) + "'{file}'".format(prog=PROG, file=e)) except configuration.PaperKeyError as e: print("{prog}: error: paper '{paper}' in '{file}' is missing " - "required key '{key}'.".format(prog=PROG, + "required key '{key}'".format(prog=PROG, paper=e.parent, file=e.file, key=e.key)) except configuration.PeriodKeyError as e: print("{prog}: error: teaching period '{period}' in '{file}' is " - "missing required key '{key}'.".format(prog=PROG, + "missing required key '{key}'".format(prog=PROG, period=e.parent, file=e.file, key=e.key)) @@ -50,4 +51,8 @@ period=args.period)) except configuration.PeriodError as e: print("{prog}: error: no entry for teaching period '{period}' in " - "'{file}'.".format(prog=PROG, file=e, period=args.period)) + "'{file}'".format(prog=PROG, file=e, period=args.period)) + except TemplateNotFound as e: + print("{prog}: error: no template found for output style '{style}' " + "and output format '{format}' (expected '{file}')".format( + prog=PROG, style=args.style, format=args.format, file=e))