From 9dbcd2c8a20ed8ef5c3e03afc1b91c3a49d500ab Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 20 Nov 2022 23:03:26 +0100 Subject: [PATCH] =?UTF-8?q?Am=C3=A9liore=20gestion=20font=20pdf=20manquant?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_bulletins_pdf.py | 2 +- app/scodoc/sco_bulletins_standard.py | 7 +++---- app/scodoc/sco_pdf.py | 8 ++++---- app/scodoc/sco_pvpdf.py | 24 ++++++++++++------------ 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/app/scodoc/sco_bulletins_pdf.py b/app/scodoc/sco_bulletins_pdf.py index fbf9bd3f..f063f3a7 100644 --- a/app/scodoc/sco_bulletins_pdf.py +++ b/app/scodoc/sco_bulletins_pdf.py @@ -184,7 +184,7 @@ def process_field(field, cdict, style, suppress_empty_pars=False, format="pdf"): # secure_filename dans la classe Logo # log('field: %s' % (text)) - return sco_pdf.makeParas(text, style, suppress_empty=suppress_empty_pars) + return sco_pdf.make_paras(text, style, suppress_empty=suppress_empty_pars) def get_formsemestre_bulletins_pdf(formsemestre_id, version="selectedevals"): diff --git a/app/scodoc/sco_bulletins_standard.py b/app/scodoc/sco_bulletins_standard.py index 45765eb2..968bbdd9 100644 --- a/app/scodoc/sco_bulletins_standard.py +++ b/app/scodoc/sco_bulletins_standard.py @@ -49,11 +49,10 @@ Balises img: actuellement interdites. from reportlab.platypus import KeepTogether, Paragraph, Spacer, Table from reportlab.lib.units import cm, mm from reportlab.lib.colors import Color, blue -from app.models import FormSemestre -from app.scodoc.sco_exceptions import ScoBugCatcher + import app.scodoc.sco_utils as scu -from app.scodoc.sco_pdf import SU +from app.scodoc.sco_pdf import SU, make_paras from app.scodoc import sco_preferences from app.scodoc.sco_permissions import Permission from app.scodoc.sco_codes_parcours import ( @@ -143,7 +142,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator): ) else: H.append("""

Pas d'absences signalées.

""") - story.append(Paragraph(SU("Pas d'absences signalées."), self.CellStyle)) + story += make_paras("Pas d'absences signalées.", self.CellStyle) # ---- APPRECIATIONS # le dir. des etud peut ajouter des appreciations, diff --git a/app/scodoc/sco_pdf.py b/app/scodoc/sco_pdf.py index d275dc0b..110917e1 100755 --- a/app/scodoc/sco_pdf.py +++ b/app/scodoc/sco_pdf.py @@ -117,7 +117,7 @@ def _splitPara(txt): return L -def makeParas(txt, style, suppress_empty=False): +def make_paras(txt: str, style, suppress_empty=False) -> list[Paragraph]: """Returns a list of Paragraph instances from a text with one or more ... """ @@ -158,9 +158,9 @@ def makeParas(txt, style, suppress_empty=False): style, ) ] - except ValueError as exc2: # probleme font ? essaye sans style - # recupere font en cause ? - m = re.match(r".*family/bold/italic for (.*)", e.args[0], re.DOTALL) + except ValueError: # probleme font ? essaye sans style + # récupère font en cause ? + m = re.match(r".*family/bold/italic for (.*)", exc.args[0], re.DOTALL) if m: message = f"police non disponible: {m[1]}" else: diff --git a/app/scodoc/sco_pvpdf.py b/app/scodoc/sco_pvpdf.py index a0fbf6cd..70e80c93 100644 --- a/app/scodoc/sco_pvpdf.py +++ b/app/scodoc/sco_pvpdf.py @@ -94,7 +94,7 @@ def page_footer(canvas, doc, logo, preferences, with_page_numbers=True): right_foot_style.fontSize = preferences["SCOLAR_FONT_SIZE_FOOT"] right_foot_style.alignment = TA_RIGHT - p = sco_pdf.makeParas( + p = sco_pdf.make_paras( f"""{preferences["INSTITUTION_NAME"]}{ preferences["INSTITUTION_ADDRESS"]}""", left_foot_style, @@ -585,7 +585,7 @@ def pdf_lettre_individuelle(sem, decision, etud: Identite, params, signature=Non or "" ) % params sig = _simulate_br(sig, '') - objects += sco_pdf.makeParas( + objects += sco_pdf.make_paras( ( """""" + sig @@ -602,7 +602,7 @@ def pdf_lettre_individuelle(sem, decision, etud: Identite, params, signature=Non or "" ) % params sig = _simulate_br(sig, '') - objects += sco_pdf.makeParas( + objects += sco_pdf.make_paras( ( """""" + sig @@ -779,7 +779,7 @@ def _pvjury_pdf_type( bulletStyle.spaceAfter = 5 * mm objects += [Spacer(0, 5 * mm)] - objects += sco_pdf.makeParas( + objects += sco_pdf.make_paras( """ Procès-verbal de %s du département %s - Session unique %s """ @@ -791,7 +791,7 @@ def _pvjury_pdf_type( style, ) - objects += sco_pdf.makeParas( + objects += sco_pdf.make_paras( """ %s """ @@ -800,20 +800,20 @@ def _pvjury_pdf_type( ) if showTitle: - objects += sco_pdf.makeParas( + objects += sco_pdf.make_paras( """Semestre: %s""" % sem["titre"], style ) if sco_preferences.get_preference("PV_TITLE_WITH_VDI", formsemestre_id): - objects += sco_pdf.makeParas( + objects += sco_pdf.make_paras( """VDI et Code: %s""" % (VDICode or ""), style ) if date_jury: - objects += sco_pdf.makeParas( + objects += sco_pdf.make_paras( """Jury tenu le %s""" % date_jury, style ) - objects += sco_pdf.makeParas( + objects += sco_pdf.make_paras( "" + (sco_preferences.get_preference("PV_INTRO", formsemestre_id) or "") % { @@ -828,7 +828,7 @@ def _pvjury_pdf_type( bulletStyle, ) - objects += sco_pdf.makeParas( + objects += sco_pdf.make_paras( """Le jury propose les décisions suivantes :""", style ) objects += [Spacer(0, 4 * mm)] @@ -881,7 +881,7 @@ def _pvjury_pdf_type( objects.append(Table(Pt, repeatRows=1, colWidths=widths, style=table_style)) # Signature du directeur - objects += sco_pdf.makeParas( + objects += sco_pdf.make_paras( """ %s, %s""" % ( @@ -894,7 +894,7 @@ def _pvjury_pdf_type( # Légende des codes codes = list(sco_codes_parcours.CODES_EXPL.keys()) codes.sort() - objects += sco_pdf.makeParas( + objects += sco_pdf.make_paras( """ Codes utilisés :""", style,