fully implemented project

This commit is contained in:
2026-01-22 19:17:50 +01:00
parent aea6950bfe
commit 42d2758ba5
11 changed files with 220 additions and 5 deletions

23
app/filter.py Normal file
View File

@@ -0,0 +1,23 @@
from ics import Calendar
td_titles = ["TD"]
sh_titles = ["ANGLAIS", "Anglais", "ETHIQUE"]
def _filter_group(name: str, titles: list[str], group: str) -> bool:
for title in titles:
if title in name:
return group == "all" or group in name
return True
def _filter_event(name: str, td_group: str, sh_group: str) -> bool:
return _filter_group(name, td_titles, td_group) and _filter_group(name, sh_titles, sh_group)
def filter_calendar(calendar: Calendar, td_group: str, sh_group: str) -> Calendar:
filtered_calendar = Calendar()
for event in calendar.events:
if _filter_event(event.name, td_group, sh_group):
filtered_calendar.events.add(event)
return filtered_calendar