From a8c8da8840a3ebe7f668a08a29cc97f04f9b822f Mon Sep 17 00:00:00 2001 From: Malte Schwerhoff Date: Sat, 9 May 2020 13:13:47 +0200 Subject: [PATCH] aggr.py: added more helpful exception when cluster file template missing --- mossutils/aggr.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mossutils/aggr.py b/mossutils/aggr.py index 8ca8f9d..20df5e8 100644 --- a/mossutils/aggr.py +++ b/mossutils/aggr.py @@ -9,12 +9,14 @@ DEFAULT_CLUSTER_FILES_DIR="_clusters" DEFAULT_CLUSTERS_MATCHES_CSV_FILE="clusters-matches.csv" DEFAULT_CLUSTER_STUDENTS_CSV_FILE_PATTERN="cluster-students-{}.csv" DEFAULT_CX_COURSE_STUDENTS_CSV_FILE="cx_students.csv" +DEFAULT_JINJA_CLUSTER_TEMPLATE_FILE="./_static/clusters.html.jinja" def main( cluster_files_dir=DEFAULT_CLUSTER_FILES_DIR, clusters_matches_csv_file=DEFAULT_CLUSTERS_MATCHES_CSV_FILE, cluster_students_csv_file_pattern=DEFAULT_CLUSTER_STUDENTS_CSV_FILE_PATTERN, - cx_course_students_csv_file=DEFAULT_CX_COURSE_STUDENTS_CSV_FILE): + cx_course_students_csv_file=DEFAULT_CX_COURSE_STUDENTS_CSV_FILE, + jinja_cluster_template_file=DEFAULT_JINJA_CLUSTER_TEMPLATE_FILE): logutils.configure_level_and_format() @@ -82,7 +84,11 @@ def main( jinja2_file_loader = jinja2.FileSystemLoader(".") jinja2_env = jinja2.Environment(loader=jinja2_file_loader) - template = jinja2_env.get_template("./_static/clusters.html.jinja") + + try: + template = jinja2_env.get_template(jinja_cluster_template_file) + except jinja2.exceptions.TemplateNotFound as exception: + raise RuntimeError("Couldn't load Jinja2 template {}. Should have been created by mu-init.".format(jinja_cluster_template_file)) # output = template.render(colors=colors) # print(output) -- GitLab