From 9b9f5a162e0b21cc60261ab6597a3c228b1d06f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Mogu=C3=A9rou?= Date: Sun, 14 Apr 2024 11:04:14 +0200 Subject: [PATCH] Sucre --- .gitignore | 3 +- colloscope/pdfexport.py | 274 +++++++++++++++++++++------------------- test.pdf | Bin 0 -> 5327 bytes 3 files changed, 143 insertions(+), 134 deletions(-) create mode 100644 test.pdf diff --git a/.gitignore b/.gitignore index 5d381cc..cdaa606 100644 --- a/.gitignore +++ b/.gitignore @@ -158,5 +158,4 @@ cython_debug/ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ - +.idea/ diff --git a/colloscope/pdfexport.py b/colloscope/pdfexport.py index 33a4c78..29e87ec 100644 --- a/colloscope/pdfexport.py +++ b/colloscope/pdfexport.py @@ -4,16 +4,16 @@ from fpdf import FPDF from fpdf.fonts import FontFace from fpdf.enums import TableCellFillMode -sem_1 = date(2023, 9, 18) - -vacances_zoneA = [ +calendrier_zoneC = date(2023, 9, 18), [ ( date(2023, 10, 21), date(2023, 11, 6) ), ( date(2023, 12, 23), date(2024, 1, 8) ), ( date(2024, 2, 10), date(2024, 2, 26) ), ( date(2024, 4, 6), date(2024, 4, 22) ), ] -def jour_of_sem(n, vac): +def jour_of_sem(n, cal): + sem_1, vac = cal + jour = sem_1 + (n-1) * timedelta(weeks=1) for (debut, fin) in vac: @@ -22,85 +22,145 @@ def jour_of_sem(n, vac): return jour +etudiants = [ + ["Aboujaib", "Alexandre", 4, "A", "Angl.", "All."], + ["Ajan", "George", 4, "A", "Angl.", ""], + ["Akrad", "Lina", 1, "SI", "Angl.", ""], + ["Aubert", "Nicolas", 1, "SI", "Angl.", ""], + ["Badr", "Roman", 4, "A", "Angl.", ""], + ["Bazire", "Aurélien", 5, "A", "Angl.", ""], + ["Boit", "Arthur", 1, "SI", "Angl.", ""], + ["Boubker", "Youssef", 1, "SI", "Angl.", ""], + ["Boudjema", "Dylan", 1, "SI", "Angl.", ""], + ["Chiriac", "Mihnea", 1, "SI", "Angl.", ""], + ["Courier", "Marine", 1, "SI", "Angl.", ""], + ["Daguin", "Joseph", 1, "SI", "Angl.", ""], + ["De Weer", "Matthias", 1, "SI", "Angl.", ""], + ["Desbouis", "Katell", 1, "SI", "Angl.", ""], + ["Dupouy", "Jérémie", 1, "SI", "Angl.", ""], + ["Hariri--Gautier-Picard", "Grégoire", 1, "SI", "Angl.", ""], + ["Juricevic", "Matteo", 1, "SI", "Angl.", ""], + ["Knanoua", "Anas", 1, "SI", "Angl.", ""], + ["Lesenne", "Pierrick", 1, "SI", "Angl.", ""], + ["Lin", "Hao", 1, "SI", "Angl.", ""], + ["Masbatin", "Lucas", 1, "SI", "Angl.", ""], + ["Mayuran", "Mithushan", 1, "SI", "Angl.", ""], + ["Messahli", "Yassine", 1, "SI", "Angl.", ""], + ["Moguérou", "Valentin", 10, "B", "Angl.", "All."], + ["Mohellebi", "Mathéo", 10, "B", "Angl.", "All."], + ["Mouisset--Ferrara", "Maël", 10, "B", "Angl.", "All."], + ["Ottavi", "Corentin", 10, "B", "Angl.", "All."], + ["Ponce", "Alexian", 10, "B", "Angl.", "All."], + ["Pujol", "Raphaël", 10, "B", "Angl.", "All."], + ["Pustetto", "Mathis", 10, "B", "Angl.", "All."], + ["Radice", "Roman", 10, "B", "Angl.", "All."], + ["Rat", "Evelyn", 10, "B", "Angl.", "All."], + ["Rousse", "Louis", 10, "B", "Angl.", "All."], + ["Roux", "Gaëtan", 10, "B", "Angl.", "All."], + ["Rouyre--Cros", "Célian", 10, "B", "Angl.", "All."], + ["Sourbé", "François-Gabriel", 10, "B", "Angl.", "All."], + ["Stourbe", "Simon", 10, "B", "Angl.", "All."], + ["Thai", "Dany", 10, "B", "Angl.", "All."], + ["Théodore", "Jonathan", 10, "B", "Angl.", "All."], + ["Vandroux", "Benoît", 10, "B", "Angl.", "All."], + ["Veyssière", "Thibaud", 10, "B", "Angl.", "All."], + ["Vié", "Adrien", 10, "B", "Angl.", "All."], + ["Ye", "Luan", 10, "B", "Angl.", "All."], + ["Zarka", "Amélie", 10, "B", "Angl.", "All."], +] + +creneaux = [ + ["Mathématiques", "vendredi", "17:00", "M. OUBAHA", "C382"], + ["Anglais", "mercredi", "14:00", "Mme LE GOURIELLEC", "C393"], + ["Mathématiques", "mercredi", "15:00", "M. BOULLY", "R004"], + ["Physique", "mardi", "14:00", "Mme CHEVALIER", "R103"], + ["Mathématiques", "mardi", "18:00", "M. RAPIN", "V152"], + ["Anglais", "mardi", "14:00", "Mme BELAGGOUNE", "C4??"], + ["pas de colle", "", "", "", ""], + ["Physique", "mardi", "17:00", "M. COLIN", "C386"], + ["Mathématiques", "mercredi", "13:30", "M. BOUVEROT", "??"], + ["Anglais", "lundi", "13:00", "M. HERBAUT", "V052"], +] + +semaines = list(range(24, 34)) + +rotations = [ + # [semaine, groupe, creneau] + (24, 1, 1), + (24, 2, 2), + (24, 3, 3), + (27, 3, 3), + (28, 3, 3), + (31, 3, 3), +] + +class PDF(FPDF): + def liste_eleves(self, etudiants): + with self.table( + align="RIGHT", + col_widths=(50, 35, 12, 12, 12, 12), + width=80, + line_height=3) as table: + header = table.row() + for th in ("Nom", "Prénom", "Grp.", "TD", "LV1", "LV2"): + header.cell(th) + + for etu in etudiants: + row = table.row() + row.cell(etu[0].upper()) # Nom + row.cell(etu[1]) # Prénom + row.cell(str(etu[2])) # Groupe + row.cell(etu[3]) # TD + row.cell(etu[4]) # LV1 + row.cell(etu[5]) # LV2 + + + def table_colloscope(self, creneaux, semaines, rotations): + with self.table( + align="LEFT", + width=190, + line_height=3, + col_widths=(25, 12, 10, 25, 12, *(10,)*len(semaines)), + num_heading_rows=2) as table: + + header = table.row() + for th in ("Matière", "Jour", "Heure", "Colleur", "Salle"): + header.cell(th, align="CENTER", rowspan=2) + + for sem in semaines: + header.cell(str(sem), align="CENTER") + + header2 = table.row() + for sem in semaines: + header2.cell(jour_of_sem(sem, calendrier_zoneC).strftime("%d/%m/%y"), align="CENTER") + + for i, tr in enumerate(creneaux): + matiere, jour, heure, colleur, salle = tr + + row = table.row() + row.cell(matiere) + row.cell(jour) + row.cell(heure) + row.cell(colleur) + row.cell(salle) + + for s in semaines: + for rot in rotations: + if rot[2] == i and rot[0] == s: + row.cell(str(rot[1]), align="CENTER") + break + else: + row.cell() + + + def generate(): - pdf = FPDF(orientation="landscape", format="A4") + pdf = PDF(orientation="landscape", format="a4") pdf.set_font("helvetica", size=6) - pdf.set_title("Colloscope MP2I Semestre 5/2") - pdf.set_author("Projet colloscope") - pdf.set_author("Projet colloscope") - - etudiants = [ - ["Aboujaib", "Alexandre", 4, "A", "Angl.", "All."], - ["Ajan", "George", 4, "A", "Angl.", ""], - ["Akrad", "Lina", 1, "SI", "Angl.", ""], - ["Aubert", "Nicolas", 1, "SI", "Angl.", ""], - ["Badr", "Roman", 4, "A", "Angl.", ""], - ["Bazire", "Aurélien", 5, "A", "Angl.", ""], - ["Boit", "Arthur", 1, "SI", "Angl.", ""], - ["Boubker", "Youssef", 1, "SI", "Angl.", ""], - ["Boudjema", "Dylan", 1, "SI", "Angl.", ""], - ["Chiriac", "Mihnea", 1, "SI", "Angl.", ""], - ["Courier", "Marine", 1, "SI", "Angl.", ""], - ["Daguin", "Joseph", 1, "SI", "Angl.", ""], - ["De Weer", "Matthias", 1, "SI", "Angl.", ""], - ["Desbouis", "Katell", 1, "SI", "Angl.", ""], - ["Dupouy", "Jérémie", 1, "SI", "Angl.", ""], - ["Hariri--Gautier-Picard", "Grégoire", 1, "SI", "Angl.", ""], - ["Juricevic", "Matteo", 1, "SI", "Angl.", ""], - ["Knanoua", "Anas", 1, "SI", "Angl.", ""], - ["Lesenne", "Pierrick", 1, "SI", "Angl.", ""], - ["Lin", "Hao", 1, "SI", "Angl.", ""], - ["Masbatin", "Lucas", 1, "SI", "Angl.", ""], - ["Mayuran", "Mithushan", 1, "SI", "Angl.", ""], - ["Messahli", "Yassine", 1, "SI", "Angl.", ""], - ["Moguérou", "Valentin", 10, "B", "Angl.", "All."], - ["Mohellebi", "Mathéo", 10, "B", "Angl.", "All."], - ["Mouisset--Ferrara", "Maël", 10, "B", "Angl.", "All."], - ["Ottavi", "Corentin", 10, "B", "Angl.", "All."], - ["Ponce", "Alexian", 10, "B", "Angl.", "All."], - ["Pujol", "Raphaël", 10, "B", "Angl.", "All."], - ["Pustetto", "Mathis", 10, "B", "Angl.", "All."], - ["Radice", "Roman", 10, "B", "Angl.", "All."], - ["Rat", "Evelyn", 10, "B", "Angl.", "All."], - ["Rousse", "Louis", 10, "B", "Angl.", "All."], - ["Roux", "Gaëtan", 10, "B", "Angl.", "All."], - ["Rouyre--Cros", "Célian", 10, "B", "Angl.", "All."], - ["Sourbé", "François-Gabriel", 10, "B", "Angl.", "All."], - ["Stourbe", "Simon", 10, "B", "Angl.", "All."], - ["Thai", "Dany", 10, "B", "Angl.", "All."], - ["Théodore", "Jonathan", 10, "B", "Angl.", "All."], - ["Vandroux", "Benoît", 10, "B", "Angl.", "All."], - ["Veyssière", "Thibaud", 10, "B", "Angl.", "All."], - ["Vié", "Adrien", 10, "B", "Angl.", "All."], - ["Ye", "Luan", 10, "B", "Angl.", "All."], - ["Zarka", "Amélie", 10, "B", "Angl.", "All."], - ] - - creneaux = [ - ["Mathématiques", "vendredi", "17:00", "M. OUBAHA", "C382"], - ["Anglais", "mercredi", "14:00", "Mme LE GOURIELLEC", "C393"], - ["Mathématiques", "mercredi", "15:00", "M. BOULLY", "R004"], - ["Physique", "mardi", "14:00", "Mme CHEVALIER", "R103"], - ["Mathématiques", "mardi", "18:00", "M. RAPIN", "V152"], - ["Anglais", "mardi", "14:00", "Mme BELAGGOUNE", "C4??"], - ["pas de colle", "", "", "", ""], - ["Physique", "mardi", "17:00", "M. COLIN", "C386"], - ["Mathématiques", "mercredi", "13:30", "M. BOUVEROT", "??"], - ["Anglais", "lundi", "13:00", "M. HERBAUT", "V052"], - ] - - semaines = list(range(24, 34)) - - rotations = [ - # [semaine, groupe, creneau] - (24, 1, 1), - (24, 2, 2), - (24, 3, 3), - (27, 3, 3), - (28, 3, 3), - (31, 3, 3), - ] + pdf.set_title("colloscope mp2i semestre 5/2") + pdf.set_author("projet colloscope") + pdf.set_author("projet colloscope") pdf.add_page() @@ -110,61 +170,11 @@ def generate(): pdf.set_y(base_y) - with pdf.table( - align="RIGHT", - col_widths=(50, 35, 12, 12, 12, 12), - width=80, - line_height=3) as table: - header = table.row() - for th in ("Nom", "Prénom", "Grp.", "TD", "LV1", "LV2"): - header.cell(th) - - for etu in etudiants: - row = table.row() - row.cell(etu[0].upper()) # Nom - row.cell(etu[1]) # Prénom - row.cell(str(etu[2])) # Groupe - row.cell(etu[3]) # TD - row.cell(etu[4]) # LV1 - row.cell(etu[5]) # LV2 + pdf.liste_eleves(etudiants) pdf.set_y(base_y) - with pdf.table( - align="LEFT", - width=190, - line_height=3, - col_widths=(25, 12, 10, 25, 12, *(10,)*len(semaines)), - num_heading_rows=2) as table: - - header = table.row() - for th in ("Matière", "Jour", "Heure", "Colleur", "Salle"): - header.cell(th, align="CENTER", rowspan=2) - - for sem in semaines: - header.cell(str(sem), align="CENTER") - - header2 = table.row() - for sem in semaines: - header2.cell(jour_of_sem(sem, vacances_zoneA).strftime("%d/%m/%y"), align="CENTER") - - for i, tr in enumerate(creneaux): - matiere, jour, heure, colleur, salle = tr - - row = table.row() - row.cell(matiere) - row.cell(jour) - row.cell(heure) - row.cell(colleur) - row.cell(salle) - - for s in semaines: - for rot in rotations: - if rot[2] == i and rot[0] == s: - row.cell(str(rot[1]), align="CENTER") - break - else: - row.cell() + pdf.table_colloscope(creneaux, semaines, rotations) pdf.output("test.pdf") diff --git a/test.pdf b/test.pdf new file mode 100644 index 0000000000000000000000000000000000000000..f3b2b2a638a2de24147f786af6b1b85ffc75ddef GIT binary patch literal 5327 zcmbuDc|4SB-@p$ZrpDF@V<}8Uh%xrD$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