Sucre
This commit is contained in:
parent
dd3727a442
commit
9b9f5a162e
|
@ -158,5 +158,4 @@ cython_debug/
|
||||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
# 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
|
# 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.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
.idea/
|
||||||
|
|
||||||
|
|
|
@ -4,16 +4,16 @@ from fpdf import FPDF
|
||||||
from fpdf.fonts import FontFace
|
from fpdf.fonts import FontFace
|
||||||
from fpdf.enums import TableCellFillMode
|
from fpdf.enums import TableCellFillMode
|
||||||
|
|
||||||
sem_1 = date(2023, 9, 18)
|
calendrier_zoneC = date(2023, 9, 18), [
|
||||||
|
|
||||||
vacances_zoneA = [
|
|
||||||
( date(2023, 10, 21), date(2023, 11, 6) ),
|
( date(2023, 10, 21), date(2023, 11, 6) ),
|
||||||
( date(2023, 12, 23), date(2024, 1, 8) ),
|
( date(2023, 12, 23), date(2024, 1, 8) ),
|
||||||
( date(2024, 2, 10), date(2024, 2, 26) ),
|
( date(2024, 2, 10), date(2024, 2, 26) ),
|
||||||
( date(2024, 4, 6), date(2024, 4, 22) ),
|
( 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)
|
jour = sem_1 + (n-1) * timedelta(weeks=1)
|
||||||
|
|
||||||
for (debut, fin) in vac:
|
for (debut, fin) in vac:
|
||||||
|
@ -22,85 +22,145 @@ def jour_of_sem(n, vac):
|
||||||
|
|
||||||
return jour
|
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():
|
def generate():
|
||||||
pdf = FPDF(orientation="landscape", format="A4")
|
pdf = PDF(orientation="landscape", format="a4")
|
||||||
pdf.set_font("helvetica", size=6)
|
pdf.set_font("helvetica", size=6)
|
||||||
|
|
||||||
pdf.set_title("Colloscope MP2I Semestre 5/2")
|
pdf.set_title("colloscope mp2i semestre 5/2")
|
||||||
pdf.set_author("Projet colloscope")
|
pdf.set_author("projet colloscope")
|
||||||
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.add_page()
|
pdf.add_page()
|
||||||
|
|
||||||
|
@ -110,61 +170,11 @@ def generate():
|
||||||
|
|
||||||
pdf.set_y(base_y)
|
pdf.set_y(base_y)
|
||||||
|
|
||||||
with pdf.table(
|
pdf.liste_eleves(etudiants)
|
||||||
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.set_y(base_y)
|
pdf.set_y(base_y)
|
||||||
|
|
||||||
with pdf.table(
|
pdf.table_colloscope(creneaux, semaines, rotations)
|
||||||
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.output("test.pdf")
|
pdf.output("test.pdf")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue