ajout edt semestre 2

This commit is contained in:
joseph 2024-02-12 15:00:25 +01:00
parent 1e771544aa
commit 3d9995773e
5 changed files with 310 additions and 77 deletions

View File

@ -1,5 +1,5 @@
BEGIN:VCALENDAR
PRODID:-//mp2i-vms//Stackity Bot Inc//EN
PRODID:-//mp2i-vms-[2]-(23-24)-s2//Stackity Bot Inc//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH

View File

@ -0,0 +1,73 @@
;Semaine;;;;;;;18;19;20;21;22;23
;;;;;;;;26/02/24;04/03/24;11/03/24;18/03/24;25/03/24;01/04/24
type;matière;jour;heure;durée;colleur;récurrent (semaines);salle;;;;;;
;;;;;;;;;;;;;
colle;Mathématiques;vendredi;17h;1h;M. OUBAHA;;C382;2;3;4;5;6;7
colle;Anglais;mercredi;14h;1h;Mme. LE GOURIELLEC;;C393;2;3;4;1;2;3
colle;Mathématiques;mercredi;15h;1h;M. BOULLY;;R004;3;4;5;6;7;8
colle;Physique;mardi;14h;1h;Mme. CHEVALIER;;R103;9;4;5;6;7;8
colle;Mathématiques;mardi;18h;1h;M. RAPIN;;V152;4;5;6;7;8;9
colle;Anglais;mardi;14h;1h;Mme. BELAGOUNE;;C454;14;15;6;7;8;9
;pas de colle;;;;;;;5;6;7;8;9;10
colle;Physique;mardi;17h;1h;M. COLIN;;C386;5;6;7;8;9;10
colle;Mathématiques;mercredi;13h30;1h;M. BOUVEROT;;;6;7;8;9;10;11
colle;Anglais;lundi;13h;1h;M. HERBAUT;;V052;6;7;8;9;10;11
colle;Mathématiques;mardi;14h;1h;Mme. MULLAERT;;M070;7;8;9;10;11;12
colle;Physique;mercredi;17h;1h;M. POUPY;;R012;7;8;9;10;11;12
;pas de colle;;;;;;;;;;;;
colle;Anglais;mercredi;16h;1h;Mme. MANN;;C380;8;9;10;11;12;13
;pas de colle;;;;;;;9;10;11;12;13;14
colle;Physique;mardi;17h;1h;Mme. CHEVALIER;;R103;3;10;1;2;3;14
colle;Mathématiques;mercredi;13h;1h;M. CARPINTERO;;V152;10;11;12;13;14;15
colle;Anglais;mercredi;15h;1h;Mme. LE GOURIELLEC;;C393;10;11;12;13;14;1
colle;Mathématiques;mercredi;14h30;1h;M. BOUVEROT;;;11;12;13;14;15;13
colle;Physique;jeudi;18h;1h;M. DE ROUX;;C054;11;12;13;14;15;
colle;Mathématiques;vendredi;18h;1h;M. OUBAHA;;C382;12;13;14;15;12;1
colle;Anglais;jeudi;15h;1h;Mme. BELAGOUNE;;C386;12;13;14;15;;15
;pas de colle;;;;;;;13;14;15;11;1;2
colle;Physique;vendredi;16h;1h;Mme. CHIBANI;;C284;13;14;15;;1;2
colle;Mathématiques;mercredi;14h;1h;M. BOULLY;;R004;14;15;10;1;2;3
colle;Anglais;jeudi;14h;1h;Mme. BELAGOUNE;;C386;4;5;;5;6;7
colle;Mathématiques;jeudi;18h;1h;M. RAPIN;;C284;15;9;1;2;3;4
colle;Physique;lundi;12h;1h;Mme. CHEVALIER;;R105;15;;11;12;13;4
colle;Mathématiques;mercredi;14h;1h;M. CARPINTERO;;V152;8;1;2;3;4;5
colle;Anglais;mercredi;17h;1h;Mme. MANN;;C380;;1;2;3;4;5
;pas de colle;;;;;;;1;2;3;4;5;6
colle;Physique;mercredi;18h;1h;M. POUPY;;R012;1;2;3;4;5;6
colle;Informatique;lundi;12h;1h;M. JOSPIN;;;13;4;9;6;11;7
colle;Informatique;lundi;13h;1h;M. JOSPIN;;;14;8;15;5;13;8
colle;TP Info;mercredi;14h;2h;;;;5,12,15;10,9,13;11,6,14;4,7,8;5,9,10;6,15,12
colle;TP Info;mercredi;16h;2h;;;;6,11,9;7,14,10;4,5,8;12,13,15;;
;;;;;;;;;;;;;
cours;TP Physique;lundi;8h30;1h30;Mme CHEVALIER;1;R417;gr 9 à 15;gr 9 à 15;gr 9 à 15;gr 9 à 15;gr 9 à 15;gr 9 à 15
cours;TP Physique;lundi;10h;1h30;Mme CHEVALIER;1;R417;gr 1 à 8;gr 1 à 8;gr 1 à 8;gr 1 à 8;gr 1 à 8;gr 1 à 8
cours;TP Info;lundi;10h;1h30;M. HALFON;2;C154;gr 9 à 15;gr 9 à 15;gr 9 à 15;gr 9 à 15;gr 9 à 15;gr 9 à 15
cours;TP Info;lundi;8h30;1h30;M. HALFON;2;C154;gr 4 à 8;gr 4 à 8;gr 4 à 8;gr 4 à 8;gr 4 à 8;gr 4 à 8
cours;TD Maths;vendredi;11h;2h;Mme MULLAERT;2;M103;B+2+3;A+1;B+2+3;A+1;B+2+3;A+1
cours;TD Maths;vendredi;14h;2h;Mme MULLAERT;2;M103;A+1;B+2+3;A+1;B+2+3;A+1;B+2+3
cours;TP Info;vendredi;14h;2h;M. HALFON;2;;B;A;B;A;B;A
cours;TP Info;vendredi;11h;2h;M. HALFON;2;;A;B;A;B;A;B
cours;TD Physique;jeudi;14h;1h;Mme CHEVALIER;1;R011;gr 9 à 15;gr 9 à 15;gr 9 à 15;gr 9 à 15;gr 9 à 15;gr 9 à 15
cours;TD Physique;jeudi;15h;1h;Mme CHEVALIER;1;R011;gr 1 à 8;gr 1 à 8;gr 1 à 8;gr 1 à 8;gr 1 à 8;gr 1 à 8
cours;Info;jeudi;10h;3h;M. HALFON;1;;A+B;;;;;
cours ;Chimie;jeudi;10h;2h;Mme CHEVALIER;1;R101;SI;;;;;
cours;TIPE Physique;jeudi;12h;0h30;Mme CHEVALIER;1;R101;SI;;;;;
cours;TP ITC ;jeudi;13h30;1h30;M. HALFON;1;;SI;;;;;
cours;TP SI;lundi;8h;2h;M. DERUMAUX;1;;SI;;;;;
cours;TIPE Physique;lundi;11h30;0h30;Mme CHEVALIER;1;;SI;;;;;
cours;SI;lundi;12h;1h;M. DERUMAUX;1;;SI;;;;;
cours;SI;mardi;14h;1h;M. DERUMAUX;1;;SI;;;;;
cours ;Maths;lundi;14h;4h;Mme MULLAERT;1;M103;A+B+SI;;;;;
cours;Maths;mardi;8h;3h;Mme MULLAERT;1;M103;A+B+SI;;;;;
cours;Physique;mardi;15h;2h;Mme CHEVALIER;1;R013;A+B+SI;;;;;
cours ;Français-Philo;mercredi;10h;2h;Mme CHAPIRO;1;M103;A+B+SI;;;;;
cours;Physique;jeudi;8h;2h;Mme CHEVALIER;1;R101;A+B+SI;;;;;
cours;EPS;jeudi;16h;2h;M. TORRES-LACAZE;1;Gymnase;A+B+SI;;;;;
cours;Maths;vendredi;8h;3h;Mme MULLAERT;1;M103;A+B+SI;;;;;
;;;;;;;;;;;;;
cours;Anglais LV1;mardi;11h;2h;;1;;;;;;;
cours;Anglais LV2;mardi ;11h;1h30;;1;;;;;;;
cours;Espagnol LV1;mercredi;8h;2h;;1;;;;;;;
cours;Espagnol LV1;mercredi;8h30;1h30;;1;;;;;;;
cours;Allemand LV1 ;mercredi;8h;2h;;1;;;;;;;
cours;Allemand LV2;mercredi;8h30;1h30;;1;;;;;;;
1 Semaine 18 19 20 21 22 23
2 26/02/24 04/03/24 11/03/24 18/03/24 25/03/24 01/04/24
3 type matière jour heure durée colleur récurrent (semaines) salle
4
5 colle Mathématiques vendredi 17h 1h M. OUBAHA C382 2 3 4 5 6 7
6 colle Anglais mercredi 14h 1h Mme. LE GOURIELLEC C393 2 3 4 1 2 3
7 colle Mathématiques mercredi 15h 1h M. BOULLY R004 3 4 5 6 7 8
8 colle Physique mardi 14h 1h Mme. CHEVALIER R103 9 4 5 6 7 8
9 colle Mathématiques mardi 18h 1h M. RAPIN V152 4 5 6 7 8 9
10 colle Anglais mardi 14h 1h Mme. BELAGOUNE C454 14 15 6 7 8 9
11 pas de colle 5 6 7 8 9 10
12 colle Physique mardi 17h 1h M. COLIN C386 5 6 7 8 9 10
13 colle Mathématiques mercredi 13h30 1h M. BOUVEROT 6 7 8 9 10 11
14 colle Anglais lundi 13h 1h M. HERBAUT V052 6 7 8 9 10 11
15 colle Mathématiques mardi 14h 1h Mme. MULLAERT M070 7 8 9 10 11 12
16 colle Physique mercredi 17h 1h M. POUPY R012 7 8 9 10 11 12
17 pas de colle
18 colle Anglais mercredi 16h 1h Mme. MANN C380 8 9 10 11 12 13
19 pas de colle 9 10 11 12 13 14
20 colle Physique mardi 17h 1h Mme. CHEVALIER R103 3 10 1 2 3 14
21 colle Mathématiques mercredi 13h 1h M. CARPINTERO V152 10 11 12 13 14 15
22 colle Anglais mercredi 15h 1h Mme. LE GOURIELLEC C393 10 11 12 13 14 1
23 colle Mathématiques mercredi 14h30 1h M. BOUVEROT 11 12 13 14 15 13
24 colle Physique jeudi 18h 1h M. DE ROUX C054 11 12 13 14 15
25 colle Mathématiques vendredi 18h 1h M. OUBAHA C382 12 13 14 15 12 1
26 colle Anglais jeudi 15h 1h Mme. BELAGOUNE C386 12 13 14 15 15
27 pas de colle 13 14 15 11 1 2
28 colle Physique vendredi 16h 1h Mme. CHIBANI C284 13 14 15 1 2
29 colle Mathématiques mercredi 14h 1h M. BOULLY R004 14 15 10 1 2 3
30 colle Anglais jeudi 14h 1h Mme. BELAGOUNE C386 4 5 5 6 7
31 colle Mathématiques jeudi 18h 1h M. RAPIN C284 15 9 1 2 3 4
32 colle Physique lundi 12h 1h Mme. CHEVALIER R105 15 11 12 13 4
33 colle Mathématiques mercredi 14h 1h M. CARPINTERO V152 8 1 2 3 4 5
34 colle Anglais mercredi 17h 1h Mme. MANN C380 1 2 3 4 5
35 pas de colle 1 2 3 4 5 6
36 colle Physique mercredi 18h 1h M. POUPY R012 1 2 3 4 5 6
37 colle Informatique lundi 12h 1h M. JOSPIN 13 4 9 6 11 7
38 colle Informatique lundi 13h 1h M. JOSPIN 14 8 15 5 13 8
39 colle TP Info mercredi 14h 2h 5,12,15 10,9,13 11,6,14 4,7,8 5,9,10 6,15,12
40 colle TP Info mercredi 16h 2h 6,11,9 7,14,10 4,5,8 12,13,15
41
42 cours TP Physique lundi 8h30 1h30 Mme CHEVALIER 1 R417 gr 9 à 15 gr 9 à 15 gr 9 à 15 gr 9 à 15 gr 9 à 15 gr 9 à 15
43 cours TP Physique lundi 10h 1h30 Mme CHEVALIER 1 R417 gr 1 à 8 gr 1 à 8 gr 1 à 8 gr 1 à 8 gr 1 à 8 gr 1 à 8
44 cours TP Info lundi 10h 1h30 M. HALFON 2 C154 gr 9 à 15 gr 9 à 15 gr 9 à 15 gr 9 à 15 gr 9 à 15 gr 9 à 15
45 cours TP Info lundi 8h30 1h30 M. HALFON 2 C154 gr 4 à 8 gr 4 à 8 gr 4 à 8 gr 4 à 8 gr 4 à 8 gr 4 à 8
46 cours TD Maths vendredi 11h 2h Mme MULLAERT 2 M103 B+2+3 A+1 B+2+3 A+1 B+2+3 A+1
47 cours TD Maths vendredi 14h 2h Mme MULLAERT 2 M103 A+1 B+2+3 A+1 B+2+3 A+1 B+2+3
48 cours TP Info vendredi 14h 2h M. HALFON 2 B A B A B A
49 cours TP Info vendredi 11h 2h M. HALFON 2 A B A B A B
50 cours TD Physique jeudi 14h 1h Mme CHEVALIER 1 R011 gr 9 à 15 gr 9 à 15 gr 9 à 15 gr 9 à 15 gr 9 à 15 gr 9 à 15
51 cours TD Physique jeudi 15h 1h Mme CHEVALIER 1 R011 gr 1 à 8 gr 1 à 8 gr 1 à 8 gr 1 à 8 gr 1 à 8 gr 1 à 8
52 cours Info jeudi 10h 3h M. HALFON 1 A+B
53 cours Chimie jeudi 10h 2h Mme CHEVALIER 1 R101 SI
54 cours TIPE Physique jeudi 12h 0h30 Mme CHEVALIER 1 R101 SI
55 cours TP ITC jeudi 13h30 1h30 M. HALFON 1 SI
56 cours TP SI lundi 8h 2h M. DERUMAUX 1 SI
57 cours TIPE Physique lundi 11h30 0h30 Mme CHEVALIER 1 SI
58 cours SI lundi 12h 1h M. DERUMAUX 1 SI
59 cours SI mardi 14h 1h M. DERUMAUX 1 SI
60 cours Maths lundi 14h 4h Mme MULLAERT 1 M103 A+B+SI
61 cours Maths mardi 8h 3h Mme MULLAERT 1 M103 A+B+SI
62 cours Physique mardi 15h 2h Mme CHEVALIER 1 R013 A+B+SI
63 cours Français-Philo mercredi 10h 2h Mme CHAPIRO 1 M103 A+B+SI
64 cours Physique jeudi 8h 2h Mme CHEVALIER 1 R101 A+B+SI
65 cours EPS jeudi 16h 2h M. TORRES-LACAZE 1 Gymnase A+B+SI
66 cours Maths vendredi 8h 3h Mme MULLAERT 1 M103 A+B+SI
67
68 cours Anglais LV1 mardi 11h 2h 1
69 cours Anglais LV2 mardi 11h 1h30 1
70 cours Espagnol LV1 mercredi 8h 2h 1
71 cours Espagnol LV1 mercredi 8h30 1h30 1
72 cours Allemand LV1 mercredi 8h 2h 1
73 cours Allemand LV2 mercredi 8h30 1h30 1

46
Resources/eleves-v2.csv Normal file
View File

@ -0,0 +1,46 @@
Nom;Prénon;Groupe de colle;TD
ABOUJAIB;Alexandre;4;A
AJAN;George;4;A
AKRAD;Lina;1;SI
AUBERT;Nicolas;1;SI
BADR;Roman;4;A
BAZIRE;Aurélien;5;A
BOIT;Arthur;5;A
BOUBKER;Youssef;5;A
BOUDJEMA;Dylan;1;SI
CHIRIAC;Mihnea;6;A
COURIER;Marine;6;A
DAGUIN;Joseph;6;A
DAUGUEN;Gabriel;7;A
DE WEER;Matthias;7;A
DESBOUIS;Katell;2;SI
DUPOUY;Jérémie;7;A
HARIRI--GAUTIER-PICARD;Grégoire;8;A
JURICEVIC;Matteo;8;A
KNANOUA;Anas;8;A
LESENNE;Pierrick;9;A
LIN;Hao;2;SI
MASBATIN;Lucas;2;SI
MAYURAN;Mithushan;9;A
MESSAHLI;Yassine;9;A
MOGUÉROU;Valentin;10;B
MOHELLEBI;Mathéo;10;B
MOUISSET--FERRARA;Maël;10;B
OTTAVI;Corentin;11;B
PONCE;Alexian;11;B
PUJOL;Raphaël;11;B
PUSTETTO;Mathis;12;B
RADICE;Roman;12;B
RAT;Evelyn;12;B
ROUSSE;Louis;3;SI
ROUX;Gaetan;3;SI
ROUYRE--CROS;Célian;3;SI
SOURBE;François-Gabriel;13;B
STOURBE;Simon;13;B
THAI;Dany;13;B
THÉODORE;Jonathan;14;B
VANDROUX;Benoit;14;B
VEYSSIERE;Thibaud;14;B
VIÉ;Adrien;15;B
YE;Luan;15;B
ZARKA;Amélie;15;B
1 Nom Prénon Groupe de colle TD
2 ABOUJAIB Alexandre 4 A
3 AJAN George 4 A
4 AKRAD Lina 1 SI
5 AUBERT Nicolas 1 SI
6 BADR Roman 4 A
7 BAZIRE Aurélien 5 A
8 BOIT Arthur 5 A
9 BOUBKER Youssef 5 A
10 BOUDJEMA Dylan 1 SI
11 CHIRIAC Mihnea 6 A
12 COURIER Marine 6 A
13 DAGUIN Joseph 6 A
14 DAUGUEN Gabriel 7 A
15 DE WEER Matthias 7 A
16 DESBOUIS Katell 2 SI
17 DUPOUY Jérémie 7 A
18 HARIRI--GAUTIER-PICARD Grégoire 8 A
19 JURICEVIC Matteo 8 A
20 KNANOUA Anas 8 A
21 LESENNE Pierrick 9 A
22 LIN Hao 2 SI
23 MASBATIN Lucas 2 SI
24 MAYURAN Mithushan 9 A
25 MESSAHLI Yassine 9 A
26 MOGUÉROU Valentin 10 B
27 MOHELLEBI Mathéo 10 B
28 MOUISSET--FERRARA Maël 10 B
29 OTTAVI Corentin 11 B
30 PONCE Alexian 11 B
31 PUJOL Raphaël 11 B
32 PUSTETTO Mathis 12 B
33 RADICE Roman 12 B
34 RAT Evelyn 12 B
35 ROUSSE Louis 3 SI
36 ROUX Gaetan 3 SI
37 ROUYRE--CROS Célian 3 SI
38 SOURBE François-Gabriel 13 B
39 STOURBE Simon 13 B
40 THAI Dany 13 B
41 THÉODORE Jonathan 14 B
42 VANDROUX Benoit 14 B
43 VEYSSIERE Thibaud 14 B
44 VIÉ Adrien 15 B
45 YE Luan 15 B
46 ZARKA Amélie 15 B

View File

@ -5,14 +5,13 @@ from discord.ext import commands
from classes.my_cog import MyCog
from create_calendar import get_calendar, get_eleves, display
from create_calendar import get_calendar, display
from io import BytesIO
class EDT(MyCog):
def __init__(self, bot):
super().__init__(bot)
self.eleves = get_eleves()
self.bot = bot
@app_commands.command(name="edt")

View File

@ -6,10 +6,10 @@ from pathlib import Path
pd_eleves = pandas.read_csv('Resources/eleves.csv')
pd_eleves = pandas.read_csv('Resources/eleves-v2.csv', delimiter=";", header=None)
np_eleves = pd_eleves.to_numpy()
pd_colles = pandas.read_csv('Resources/colles.csv')
pd_colles = pandas.read_csv('Resources/colloscope-v2.csv', delimiter=";", header=None)
np_colles = pd_colles.to_numpy()
local_tz = "Europe/Paris"
@ -22,6 +22,15 @@ jour_to_delta = {
"vendredi": 4,
}
jour_to_byday = {
"lundi": "MO",
"mardi": "TU",
"mercredi": "WE",
"jeudi": "TH",
"vendredi": "FR",
}
langues = ["Anglais", "Allemand", "Espagnol"]
option_langues = {
@ -61,14 +70,14 @@ def add_events_from_ics(filename: str, new_cal: icalendar.Calendar):
return new_cal
def get_eleves():
def get_td_groupe(groupe: str) -> str:
"""
Renvoie la liste des eleves avec leur groupe associés à leur groupe, a utiliser dans la /cmd
Renvoie le groupe de TD d'un groupe de colle (A, B ou SI)
"""
liste = {}
for row in np_eleves[1:]:
liste[f"{row[0]} {row[1]} - {row[2]}"] = row[2]
return liste
if row[2] == groupe:
return row[3]
def debut_semaine_to_datetime(date_string: str) -> datetime.time:
"""
@ -77,6 +86,50 @@ def debut_semaine_to_datetime(date_string: str) -> datetime.time:
return datetime.datetime.strptime(date_string, "%d/%m/%y")
def heure_to_timedelta(heure: str) -> datetime.timedelta:
"""
Transforme une heure au format "8h30" ou "1h30" ou "2h" en timedelta.
"""
heure = heure.split("h")
delta = datetime.timedelta(hours=int(heure[0]))
if heure[1] != '':
delta += datetime.timedelta(minutes=int(heure[1]))
return delta
def creer_evenement(titre: str, debut: datetime.datetime, duree: datetime.timedelta, description: str = None, localisation: str = None, rrule: str = None) -> icalendar.Event:
"""
Renvoie un évènement icalendar.Event()
titre str: le titre de l'évènement
debut datetime.datetime: la date de début
duree datetime.timedelta: la durée
description str: la description (Optionelle)
localisation str: localisation (Optionelle)
rrule str: règle de récurrence https://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html (Optionelle)
"""
new_event = icalendar.Event()
new_event.add("summary", titre)
new_event.add("dtstart", debut, parameters={"tzid": local_tz})
debut += duree
new_event.add("dtend", debut, parameters={"tzid": local_tz})
if localisation is not None:
new_event.add("location", localisation)
if description is not None:
new_event.add("description", description)
if rrule is not None:
new_event.add("rrule", rrule)
new_event.add("uid", str(uuid.uuid4()))
new_event.add("dtstamp", datetime.datetime.now())
# print(f"\nNouvel évènement: \n - {titre} \n - {debut - duree} \n- {duree} \n- {localisation} \n - {rrule}")
# nécessaire pour se conformer à la norme RFC 5545
return new_event
def get_colles_groupe(np_colles, groupe, option_langue):
"""
Renvoie les colles pour un groupe sous la forme d'une liste d'évènements ICS
@ -86,47 +139,53 @@ def get_colles_groupe(np_colles, groupe, option_langue):
option_langue: str, les options de langue
"""
liste_colles = []
for row in np_colles[1:]:
for row in np_colles[4:39]:
if pandas.isnull(row[0]) or row[0] == "pas de colle":
if pandas.isnull(row[1]) or row[1] == "pas de colle":
# il n'y a pas de colle, on skip !
continue
# Si la colle n'est pas la LV1 de l'élève, on skip
if row[0] == "Anglais" and not option_langue.startswith("EN"):
if row[1] == "Anglais" and not option_langue.startswith("EN"):
continue
elif row[0] == "Allemand" and not option_langue.startswith("DE"):
elif row[1] == "Allemand" and not option_langue.startswith("DE"):
continue
elif row[0] == "Espagnol" and not option_langue.startswith("ES"):
elif row[1] == "Espagnol" and not option_langue.startswith("ES"):
continue
for index, colle in enumerate(row[5:]):
# les quatre premières cases ne sont pas
if pandas.isnull(colle) or colle != groupe:
for index, colle in enumerate(row[8:]):
if pandas.isnull(colle):
continue
# les huit premières cases ne sont pas concernées
elif colle != groupe and ("," in list(colle) and groupe not in colle.split(",")):
continue
# dans le cas où plusieurs groupes de colles soient concernés
new_colle = icalendar.Event()
new_colle.add("summary", f"Colle {row[0]}")
new_colle.add("description", f"{row[3]}")
new_colle.add("location", row[4])
duree = heure_to_timedelta(row[4])
# transforme la durée en timedelta
new_colle.add("dtstamp", datetime.datetime.now())
date = debut_semaine_to_datetime(np_colles[1][index+8])
# TODO
date += datetime.timedelta(days=jour_to_delta[row[2]])
date += heure_to_timedelta(row[3])
# génère la date à partir de la semaine, du jour et de l'heure
new_colle.add("uid", str(uuid.uuid4()))
date = debut_semaine_to_datetime(np_colles[0][index+5])
date += datetime.timedelta(days=jour_to_delta[row[1]])
date += datetime.timedelta(hours=int(row[2][:-1]))
new_colle.add("dtstart", date, parameters={"tzid": local_tz})
localisation = row[7] if not pandas.isnull(row[7]) else None
date += datetime.timedelta(hours=1)
new_colle.add("dtend", date, parameters={"tzid": local_tz})
new_colle = creer_evenement(
titre=f"Colle {row[1]}",
description=f"{row[5]}",
localisation=localisation,
debut=date,
duree=duree
)
liste_colles.append(new_colle)
return liste_colles
def get_cours_SI(np_colles, groupe):
def get_cours(np_colles, groupe):
"""
Renvoie les colles pour un groupe sous la forme d'une liste d'évènements ICS, cad
icalendar.Event
@ -134,58 +193,120 @@ def get_cours_SI(np_colles, groupe):
np_colles: l'array 2D numpy contenant le colloscope
groupe: str, le numéro du groupe
"""
liste_cours = []
for index, cell in enumerate(np_colles[-1][5:]):
heure = 17
groupes = cell.split("§")
if groupe in groupes or f"\n{groupe}" in groupes:
heure = 16
listes_cours = []
groupe_td = get_td_groupe(groupe)
cours_si = icalendar.Event()
cours_si.add("summary", "TD SI")
cours_si.add("description", "M. Derumeaux R415")
cours_si.add("dtstamp", datetime.datetime.now())
cours_si.add("uid", str(uuid.uuid4()))
for row in np_colles[41:66]:
date = debut_semaine_to_datetime(np_colles[0][index+5])
date += datetime.timedelta(days=jour_to_delta["mardi"])
date += datetime.timedelta(hours=heure)
cours_si.add("dtstart", date, parameters={"tzid": local_tz})
if pandas.isnull(row[1]):
continue
date += datetime.timedelta(hours=1)
cours_si.add("dtend", date, parameters={"tzid": local_tz})
liste_cours.append(cours_si)
first_date = np_colles[1][8]
eleves = row[8]
return liste_cours
if "à" in list(eleves):
eleves = eleves.split(" ")
debut, fin = [grp for grp in eleves if grp.isdigit()]
if not int(debut) <= int(groupe) <= int(fin):
continue
elif "+" in list(eleves):
eleves = eleves.split("+")
if groupe not in [grp for grp in eleves if grp.isdigit()]:
if groupe_td not in [grp for grp in eleves]:
if int(row[6]) > 1:
if groupe in [grp for grp in row[9].split("+") if grp.isdigit()]:
first_date = np_colles[1][9]
elif groupe_td in [grp for grp in row[9].split("+")]:
first_date = np_colles[1][9]
else:
continue
else:
continue
# si la 1ère occurence du cours est la 1ère ou la 2e semaine
elif groupe != eleves and groupe_td != eleves:
if pandas.isnull(row[9]) or (groupe != row[9] and groupe_td != row[9]):
continue
else:
first_date = np_colles[1][9]
# vérification que le groupe est concerné par le cours
first_date = debut_semaine_to_datetime(first_date)
first_date += heure_to_timedelta(row[3])
first_date += datetime.timedelta(days=jour_to_delta[row[2]])
duree = heure_to_timedelta(row[4])
localisation = row[7] if not pandas.isnull(row[7]) else None
last_date = debut_semaine_to_datetime(np_colles[1][-1]) + datetime.timedelta(days=5)
rrule = {"FREQ": "WEEKLY", "UNTIL": last_date, "INTERVAL": row[6], "BYDAY": jour_to_byday[row[2]], "WKST": "MO"}
new_cours = creer_evenement(
titre=row[1],
description=row[5],
localisation=localisation,
debut=first_date,
duree=duree,
rrule=rrule
)
listes_cours.append(new_cours)
return listes_cours
def get_langues(langues):
"""
Renvoie la liste de cours de langue associés
list[icalendar.Event]
Renvoie la liste de cours de langue associés sous forme de list[icalendar.Event]
"""
liste_langues = []
p = Path(__file__).with_name('Resources')
p = Path(p, f"EDT_Langues.ics")
with p.open('r') as f:
opened_cal = icalendar.Calendar.from_ical(f.read())
liste_cours = []
langues = option_langues[langues]
for event in opened_cal.walk("vevent"):
if event.get("summary") in option_langues[langues]:
liste_langues.append(event)
for row in np_colles[67:]:
return liste_langues
if row[1] in langues:
debut = debut_semaine_to_datetime(np_colles[1][9])
debut += heure_to_timedelta(row[3])
debut += datetime.timedelta(days=jour_to_delta[row[2]])
duree = heure_to_timedelta(row[4])
last_date = debut_semaine_to_datetime(np_colles[1][-1]) + datetime.timedelta(days=5)
rrule = {"FREQ": "WEEKLY", "UNTIL": last_date, "INTERVAL": row[6], "BYDAY": jour_to_byday[row[2]], "WKST": "MO"}
new_cours = creer_evenement(
titre=row[1],
debut=debut,
duree=duree,
rrule=rrule
)
liste_cours.append(new_cours)
return liste_cours
def get_calendar(groupe, langues, split: bool = False):
def get_calendar(groupe: str, langues: str, split: bool = False):
""""
Renvoie un calendrier (icalendar.Calendar) pour un groupe avec des langues donné
"""
moitie = None
for row in np_eleves[1:]:
if row[2] == int(groupe):
moitie = row[3]
break
new_cal_edt = open_ics("Base_Calendar.ics")
@ -193,15 +314,10 @@ def get_calendar(groupe, langues, split: bool = False):
new_cal_colles = open_ics("Base_Calendar.ics")
new_cal_edt = add_events_from_ics(filename="EDT_Base.ics", new_cal=new_cal_edt)
new_cal_edt = add_events_from_ics(filename=f"EDT_{moitie}.ics", new_cal=new_cal_edt)
for event in get_langues(langues):
new_cal_edt.add_component(event)
for event in get_cours_SI(np_colles, groupe):
for event in get_cours(np_colles, groupe):
new_cal_edt.add_component(event)
if split:
@ -214,5 +330,4 @@ def get_calendar(groupe, langues, split: bool = False):
new_cal_edt.add_component(event)
return [new_cal_edt.to_ical()]