From ec108a445400ba0561e5b60dfe06281609c3a834 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 13 Jan 2022 21:13:09 +0100 Subject: [PATCH] geb_tables: meilleur msg erreur si template pdf invalide --- app/scodoc/gen_tables.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/scodoc/gen_tables.py b/app/scodoc/gen_tables.py index a9ed10aa..2ac3c398 100644 --- a/app/scodoc/gen_tables.py +++ b/app/scodoc/gen_tables.py @@ -58,6 +58,7 @@ from app.scodoc import sco_utils as scu from app.scodoc import sco_excel from app.scodoc import sco_pdf from app.scodoc import sco_xml +from app.scodoc.sco_exceptions import ScoValueError from app.scodoc.sco_pdf import SU from app import log @@ -539,17 +540,18 @@ class GenTable(object): # # titles = ["%s" % x for x in self.get_titles_list()] pdf_style_list = [] - Pt = [ - [Paragraph(SU(str(x)), CellStyle) for x in line] - for line in ( - self.get_data_list( - pdf_mode=True, - pdf_style_list=pdf_style_list, - with_titles=True, - omit_hidden_lines=True, - ) - ) - ] + data_list = self.get_data_list( + pdf_mode=True, + pdf_style_list=pdf_style_list, + with_titles=True, + omit_hidden_lines=True, + ) + try: + Pt = [ + [Paragraph(SU(str(x)), CellStyle) for x in line] for line in data_list + ] + except ValueError as exc: + raise ScoValueError(f"Erreur dans un format pdf:
{str(exc)}") from exc pdf_style_list += self.pdf_table_style T = Table(Pt, repeatRows=1, colWidths=self.pdf_col_widths, style=pdf_style_list)