Compare commits
3 Commits
e4ffc90208
...
ecfb6d26c4
Author | SHA1 | Date |
---|---|---|
|
ecfb6d26c4 | |
|
9328bef408 | |
|
42f36c05cd |
|
@ -2,3 +2,5 @@
|
||||||
/.env
|
/.env
|
||||||
/edt.png
|
/edt.png
|
||||||
/parseSallesTemp.py
|
/parseSallesTemp.py
|
||||||
|
/~$colloscope S2.xlsx
|
||||||
|
/~$colloscope.xlsx
|
Binary file not shown.
After Width: | Height: | Size: 161 KiB |
Binary file not shown.
BIN
colloscope.xlsx
BIN
colloscope.xlsx
Binary file not shown.
63
main.py
63
main.py
|
@ -2,6 +2,7 @@ from datetime import datetime
|
||||||
import discord
|
import discord
|
||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
from parse_colles import create_colloscope
|
from parse_colles import create_colloscope
|
||||||
|
from parse_colles_s2 import create_colloscope_s2, next_colle
|
||||||
from parse_salles import create_edt, parse_edt, create_image
|
from parse_salles import create_edt, parse_edt, create_image
|
||||||
import os
|
import os
|
||||||
from dotenv import load_dotenv, dotenv_values
|
from dotenv import load_dotenv, dotenv_values
|
||||||
|
@ -228,5 +229,67 @@ async def add_colle(
|
||||||
await interaction.response.send_message(embed=embed)
|
await interaction.response.send_message(embed=embed)
|
||||||
|
|
||||||
|
|
||||||
|
@tree.command(
|
||||||
|
name="parse_colles_s2",
|
||||||
|
description="Récupérer un fichier en .ics contenant vos colles du S2",
|
||||||
|
guild=discord.Object(id=1292935532472565852),
|
||||||
|
)
|
||||||
|
@app_commands.describe(group="Votre Groupe de Colles. (1-16)")
|
||||||
|
@app_commands.describe(
|
||||||
|
timezone="Le fuseau Horaire UTC+n (laisser vide si vous ne savez pas), UTC+2 par défaut"
|
||||||
|
)
|
||||||
|
async def recup_colles_s2(
|
||||||
|
interaction: discord.Interaction, group: str, timezone: str = "Europe/Paris"
|
||||||
|
):
|
||||||
|
if 0 < int(group) < 17:
|
||||||
|
create_colloscope_s2(int(group), timezone)
|
||||||
|
await interaction.response.send_message(
|
||||||
|
content=f"Voici le fichier de colles parsé pour le groupe {group} ! ",
|
||||||
|
file=discord.File("output_s2.ics", filename=f"groupe{group}_s2.ics"),
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
await interaction.response.send_message(
|
||||||
|
content="Ce groupe n'existe pas banane !"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@tree.command(
|
||||||
|
name="next_colle",
|
||||||
|
description="Récupérer les informations de la prochaine colle du S2 pour un groupe",
|
||||||
|
guild=discord.Object(id=1292935532472565852),
|
||||||
|
)
|
||||||
|
@app_commands.describe(group="Votre Groupe de Colles. (1-16)")
|
||||||
|
@app_commands.describe(
|
||||||
|
timezone="Le fuseau Horaire UTC+n (laisser vide si vous ne savez pas), UTC+2 par défaut"
|
||||||
|
)
|
||||||
|
async def next_colle_s2(
|
||||||
|
interaction: discord.Interaction, group: str, timezone: str = "Europe/Paris"
|
||||||
|
):
|
||||||
|
if 0 < int(group) < 17:
|
||||||
|
colle_info = next_colle(int(group), timezone)
|
||||||
|
if colle_info:
|
||||||
|
embed = discord.Embed(
|
||||||
|
title=f"Prochaine Colle de {colle_info['subject']}",
|
||||||
|
description=f"""
|
||||||
|
Date : {colle_info['date']}
|
||||||
|
Jour : {colle_info['day']}
|
||||||
|
Heure de début : {colle_info['start_time']}
|
||||||
|
Heure de fin : {colle_info['end_time']}
|
||||||
|
Professeur : {colle_info['professor']}
|
||||||
|
Salle : {colle_info['room']}
|
||||||
|
""",
|
||||||
|
colour=0x00B0F4,
|
||||||
|
timestamp=datetime.now(),
|
||||||
|
)
|
||||||
|
await interaction.response.send_message(embed=embed)
|
||||||
|
else:
|
||||||
|
await interaction.response.send_message(
|
||||||
|
content=f"Aucune colle trouvée pour le groupe {group}."
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
await interaction.response.send_message(
|
||||||
|
content="Ce groupe n'existe pas banane !"
|
||||||
|
)
|
||||||
|
|
||||||
# Lancer le bot
|
# Lancer le bot
|
||||||
bot.run(os.getenv("BOT_TOKEN"))
|
bot.run(os.getenv("BOT_TOKEN"))
|
||||||
|
|
|
@ -0,0 +1,265 @@
|
||||||
|
BEGIN:VCALENDAR
|
||||||
|
VERSION:2.0
|
||||||
|
PRODID:ics.py - http://git.io/lLljaA
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Lé-Nhu\nSalle: Undef\nMatière : Maths
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250403T150000Z
|
||||||
|
SUMMARY:Colle Maths
|
||||||
|
UID:9dc4eef9-f861-4848-a646-b1f00ff348a6@9dc4.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Mullaert\nSalle: Undef\nMatière : Maths
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250505T150000Z
|
||||||
|
SUMMARY:Colle Maths
|
||||||
|
UID:cad2b6cb-c5ef-4e34-bb66-e65502fa22f1@cad2.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Lé-Nhu\nSalle: Undef\nMatière : Maths
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250327T150000Z
|
||||||
|
SUMMARY:Colle Maths
|
||||||
|
UID:01c6be59-c21c-4316-b00a-374d8fe00bca@01c6.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mr Gallic\nSalle: Undef\nMatière : Maths
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250313T170000Z
|
||||||
|
SUMMARY:Colle Maths
|
||||||
|
UID:45a10fe6-0a3f-483b-90f3-955c6d793686@45a1.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Cissokho\nSalle: Undef\nMatière : Maths
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250516T160000Z
|
||||||
|
SUMMARY:Colle Maths
|
||||||
|
UID:21569c00-b883-443a-9a1e-a1ec4f5852bb@2156.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mr Poupy\nSalle: Undef\nMatière : Physique
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250212T160000Z
|
||||||
|
SUMMARY:Colle Physique
|
||||||
|
UID:77417b65-c6ee-4318-af09-1fe736f0509f@7741.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Mann\nSalle: Undef\nMatière : Anglais
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250205T160000Z
|
||||||
|
SUMMARY:Colle Anglais
|
||||||
|
UID:9813360a-99a5-4b20-ad63-b496b8ceb835@9813.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Chibani\nSalle: Undef\nMatière : Physique
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250604T120000Z
|
||||||
|
SUMMARY:Colle Physique
|
||||||
|
UID:5145230b-d06d-45a0-9552-825e9a19af12@5145.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Sabban\nSalle: Undef\nMatière : Maths
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250611T120000Z
|
||||||
|
SUMMARY:Colle Maths
|
||||||
|
UID:34bdce8d-1725-4bb0-8d25-40387cc49d83@34bd.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Semenova\nSalle: Undef\nMatière : Anglais
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250430T130000Z
|
||||||
|
SUMMARY:Colle Anglais
|
||||||
|
UID:b5f3e118-6a5f-483f-8d32-fc742d5a386a@b5f3.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Quintin\nSalle: Undef\nMatière : Anglais
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250528T140000Z
|
||||||
|
SUMMARY:Colle Anglais
|
||||||
|
UID:9fae2e1e-6fd9-4c15-8e72-9798363cbd80@9fae.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Cissokho\nSalle: Undef\nMatière : Maths
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250606T150000Z
|
||||||
|
SUMMARY:Colle Maths
|
||||||
|
UID:46ce7bed-6abc-4fd0-a20e-d10b18e3c5e4@46ce.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mr Poupy\nSalle: Undef\nMatière : Physique
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250618T150000Z
|
||||||
|
SUMMARY:Colle Physique
|
||||||
|
UID:3af0a2e4-6f87-4efe-b3f9-f1897aaa67cb@3af0.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mr Pelletier\nSalle: Undef\nMatière : Maths
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250320T160000Z
|
||||||
|
SUMMARY:Colle Maths
|
||||||
|
UID:bd144822-ea6d-4c68-88ec-c20afc5c9a35@bd14.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mr Gallic\nSalle: Undef\nMatière : Maths
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250213T150000Z
|
||||||
|
SUMMARY:Colle Maths
|
||||||
|
UID:42722146-2cbd-4cf0-a038-68e17474f0dc@4272.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mr Annoussamy\nSalle: Undef\nMatière : Lettres
|
||||||
|
DURATION:PT1H30M
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250410T140000Z
|
||||||
|
SUMMARY:Colle Lettres
|
||||||
|
UID:58ee0d35-a666-4b7d-b06a-a1bb53184244@58ee.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mr Gauvin\nSalle: Undef\nMatière : Anglais
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250609T160000Z
|
||||||
|
SUMMARY:Colle Anglais
|
||||||
|
UID:6f7b6c17-b5bb-47e3-99a5-37a3decb4411@6f7b.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Chevalier\nSalle: Undef\nMatière : Physique
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250407T110000Z
|
||||||
|
SUMMARY:Colle Physique
|
||||||
|
UID:5c187549-e2c4-4157-8ec4-9952d4e6950c@5c18.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mr Robin\nSalle: Undef\nMatière : Physique
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250507T160000Z
|
||||||
|
SUMMARY:Colle Physique
|
||||||
|
UID:7b25a5d6-7d59-41b8-ae01-4f81e05117c7@7b25.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Mann\nSalle: Undef\nMatière : Anglais
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250319T150000Z
|
||||||
|
SUMMARY:Colle Anglais
|
||||||
|
UID:e7e4c0e2-1ccb-4314-8050-436554633074@e7e4.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mr Bouverot\nSalle: Undef\nMatière : Maths
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250205T140000Z
|
||||||
|
SUMMARY:Colle Maths
|
||||||
|
UID:4931b3a4-998f-44b1-a986-caf2226dce26@4931.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Pourcelot d’Hennezel\nSalle: Undef\nMatière : Physique
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250520T160000Z
|
||||||
|
SUMMARY:Colle Physique
|
||||||
|
UID:3649dbe9-9ebe-4c1e-82eb-72de24a6c4ac@3649.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Chibani\nSalle: Undef\nMatière : Physique
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250326T140000Z
|
||||||
|
SUMMARY:Colle Physique
|
||||||
|
UID:0ccba5d2-c6d5-4619-9b5c-0d28eefa35bb@0ccb.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Chevalier\nSalle: Undef\nMatière : Physique
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250310T120000Z
|
||||||
|
SUMMARY:Colle Physique
|
||||||
|
UID:1761dc34-8575-4d48-b5b1-ae8bbd847b2c@1761.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mr Gallic\nSalle: Undef\nMatière : Maths
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250306T170000Z
|
||||||
|
SUMMARY:Colle Maths
|
||||||
|
UID:9053dad9-7245-4bb2-9c8f-05d7bfb55b96@9053.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Mullaert\nSalle: Undef\nMatière : Maths
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250428T150000Z
|
||||||
|
SUMMARY:Colle Maths
|
||||||
|
UID:a8b556ed-16e4-43ad-84c8-f1012d3a5879@a8b5.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Mann\nSalle: Undef\nMatière : Anglais
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250514T150000Z
|
||||||
|
SUMMARY:Colle Anglais
|
||||||
|
UID:08b4b1da-c457-4ced-b3eb-ba6435210ead@08b4.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Quintin\nSalle: Undef\nMatière : Anglais
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250305T150000Z
|
||||||
|
SUMMARY:Colle Anglais
|
||||||
|
UID:46abd002-106a-4f94-a0ce-733117ae5b78@46ab.org
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DESCRIPTION:Professeur: Mme Kidscheid\nSalle: Undef\nMatière : Anglais
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Undef - Saint-Louis
|
||||||
|
ORGANIZER;CN=Groupe 1:mailto:Groupe 1
|
||||||
|
DTSTART:20250402T130000Z
|
||||||
|
SUMMARY:Colle Anglais
|
||||||
|
UID:84609f37-bb1f-452a-8933-c34daa33888c@8460.org
|
||||||
|
END:VEVENT
|
||||||
|
END:VCALENDAR
|
|
@ -0,0 +1,164 @@
|
||||||
|
import openpyxl
|
||||||
|
from datetime import datetime, timedelta, timezone
|
||||||
|
import locale
|
||||||
|
import calendar
|
||||||
|
import pytz
|
||||||
|
from ics import Calendar, Event
|
||||||
|
|
||||||
|
# Open the Excel file
|
||||||
|
|
||||||
|
def create_colloscope_s2(groupe:int, timezone:str = "Europe/Paris"):
|
||||||
|
try:
|
||||||
|
pytz.timezone(timezone)
|
||||||
|
timezone = timezone
|
||||||
|
except pytz.UnknownTimeZoneError:
|
||||||
|
timezone = "Europe/Paris"
|
||||||
|
c = Calendar()
|
||||||
|
|
||||||
|
workbook = openpyxl.load_workbook('colloscope.xlsx')
|
||||||
|
|
||||||
|
# Access a specific sheet
|
||||||
|
sheet = workbook['Colloscope S2']
|
||||||
|
|
||||||
|
# Do something with the sheet, such as reading data or modifying it
|
||||||
|
# Retrieve all coordinates where the cell value is 10
|
||||||
|
coordinates = []
|
||||||
|
for row in sheet.iter_rows():
|
||||||
|
for cell in row:
|
||||||
|
if cell.value == groupe:
|
||||||
|
coordinates.append((cell.row, cell.column))
|
||||||
|
|
||||||
|
# Retrieve additional information for each coordinate starting from the 6th row
|
||||||
|
for coordinate in coordinates:
|
||||||
|
row = coordinate[0]
|
||||||
|
if row < 6:
|
||||||
|
continue
|
||||||
|
column = coordinate[1]
|
||||||
|
matière = sheet[f'A{row}'].value
|
||||||
|
if not matière:
|
||||||
|
continue
|
||||||
|
matière = matière.capitalize()
|
||||||
|
professor = sheet[f'B{row}'].value
|
||||||
|
hour = sheet[f'D{row}'].value
|
||||||
|
room = "Undef" #sheet[f'F{row}'].value
|
||||||
|
duration = sheet[f'E{row}'].value # Assuming the duration is in column F
|
||||||
|
# Convert column number to letter
|
||||||
|
column_letter = chr(ord('A') + column - 1)
|
||||||
|
date_str = sheet[f'{column_letter}1'].value # Ligne 1 pour les dates à partir de la colonne F
|
||||||
|
if date_str is None:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
date = datetime.strptime(date_str, "%d/%m/%Y")
|
||||||
|
except ValueError:
|
||||||
|
continue
|
||||||
|
except TypeError:
|
||||||
|
date = date_str
|
||||||
|
try:
|
||||||
|
day_sem = sheet[f"C{row}"].value
|
||||||
|
except TypeError or day_sem is None:
|
||||||
|
continue
|
||||||
|
if day_sem is None:
|
||||||
|
continue
|
||||||
|
day_sem = str(day_sem).split(" ")[0].capitalize()
|
||||||
|
days = ['Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche']
|
||||||
|
days_english = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
|
||||||
|
try:
|
||||||
|
day_number_sem = days.index(day_sem)
|
||||||
|
except ValueError:
|
||||||
|
day_number_sem = days_english.index(day_sem)
|
||||||
|
# Combine day_number_sem with date
|
||||||
|
new_days = day_number_sem + date.day;
|
||||||
|
if new_days > 30 and date.month in [4, 6, 9, 11]:
|
||||||
|
new_days = new_days - 30;
|
||||||
|
new_month = date.month + 1;
|
||||||
|
elif new_days > 31 and date.month in [1, 3, 5, 7, 8, 10, 12]:
|
||||||
|
new_days = new_days - 31;
|
||||||
|
new_month = date.month + 1;
|
||||||
|
else :
|
||||||
|
new_month = date.month;
|
||||||
|
if (new_month <9):
|
||||||
|
combined_date = datetime(2025, new_month, new_days).date()
|
||||||
|
else:
|
||||||
|
combined_date = datetime(2024, new_month, new_days).date()
|
||||||
|
|
||||||
|
|
||||||
|
if professor == None:
|
||||||
|
continue;
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
start_time = datetime.strptime(hour.split('-')[0], "%Hh%M").time()
|
||||||
|
except ValueError:
|
||||||
|
start_time = datetime.strptime(hour.split('-')[0], "%Hh").time()
|
||||||
|
duration_hours = int(duration)
|
||||||
|
duration_minutes = int((duration - duration_hours) * 60)
|
||||||
|
|
||||||
|
|
||||||
|
# Calculate the end time by adding the duration to the start time
|
||||||
|
end_time = (datetime.combine(date.today(), start_time) + timedelta(hours=duration_hours, minutes=duration_minutes)).time()
|
||||||
|
|
||||||
|
# Create a new datetime object with the combined date and start time
|
||||||
|
start_datetime = datetime.combine(combined_date, start_time)
|
||||||
|
|
||||||
|
# Create a new datetime object with the combined date and end time
|
||||||
|
end_datetime = datetime.combine(combined_date, end_time)
|
||||||
|
|
||||||
|
|
||||||
|
print(f"Day: {day_sem}")
|
||||||
|
print(f"Date: {combined_date}")
|
||||||
|
print(f"Start time: {start_datetime}")
|
||||||
|
print(f"End time: {end_datetime}")
|
||||||
|
print(f"Subject: {matière}")
|
||||||
|
print(f"Professor: {professor}")
|
||||||
|
print(f"Room: {room}")
|
||||||
|
print("--------------------")
|
||||||
|
|
||||||
|
e = Event()
|
||||||
|
e.name = f"Colle {matière}"
|
||||||
|
|
||||||
|
e.begin = start_datetime.astimezone(pytz.timezone(timezone))
|
||||||
|
e.duration = timedelta(hours=duration_hours, minutes=duration_minutes)
|
||||||
|
e.location = f"{room} - Saint-Louis"
|
||||||
|
e.description = f"Professeur: {professor}\nSalle: {room}\nMatière : {matière}"
|
||||||
|
e.organizer = f"Groupe {groupe}"
|
||||||
|
e.alarms = []
|
||||||
|
c.events.add(e)
|
||||||
|
|
||||||
|
# Save the changes
|
||||||
|
workbook.save('colloscope.xlsx')
|
||||||
|
|
||||||
|
|
||||||
|
with open(f'output_s2.ics', 'w') as my_file:
|
||||||
|
my_file.writelines(c)
|
||||||
|
|
||||||
|
# Close the workbook
|
||||||
|
workbook.close()
|
||||||
|
|
||||||
|
def next_colle(groupe: int, timezone: str = "Europe/Paris"):
|
||||||
|
try:
|
||||||
|
pytz.timezone(timezone)
|
||||||
|
timezone = timezone
|
||||||
|
except pytz.UnknownTimeZoneError:
|
||||||
|
timezone = "Europe/Paris"
|
||||||
|
c = Calendar()
|
||||||
|
create_colloscope_s2(groupe, timezone)
|
||||||
|
with open(f'output_s2.ics', 'r') as my_file:
|
||||||
|
c = Calendar(my_file.read())
|
||||||
|
|
||||||
|
now = datetime.now(pytz.timezone(timezone))
|
||||||
|
next_colle_info = None
|
||||||
|
|
||||||
|
for event in c.events:
|
||||||
|
if event.begin > now:
|
||||||
|
if next_colle_info is None or event.begin < next_colle_info['start_time']:
|
||||||
|
next_colle_info = {
|
||||||
|
'day': event.begin.format('dddd', locale='fr_FR'),
|
||||||
|
'date': event.begin.date(),
|
||||||
|
'start_time': event.begin,
|
||||||
|
'end_time': event.end,
|
||||||
|
'subject': event.name.replace("Colle ", ""),
|
||||||
|
'professor': event.description.split('\n')[0].replace("Professeur: ", ""),
|
||||||
|
'room': event.location.split(' - ')[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
return next_colle_info
|
Binary file not shown.
Loading…
Reference in New Issue