fixed bug
This commit is contained in:
@@ -1,21 +1,32 @@
|
||||
from ics import Calendar
|
||||
|
||||
td_titles = ["TD"]
|
||||
sh_titles = ["ANGLAIS", "Anglais", "ETHIQUE"]
|
||||
td_groups = ["1.1", "1.2"]
|
||||
sh_titles = ["ANGLAIS", "ETHIQUE"]
|
||||
sh_groups = ["1.1", "1.2", "1.3"]
|
||||
|
||||
def _filter_group(name: str, titles: list[str], group: str, groups: list[str]) -> bool | None:
|
||||
has_group = False
|
||||
for title_group in groups:
|
||||
if title_group in name:
|
||||
has_group = True
|
||||
break
|
||||
|
||||
if not has_group:
|
||||
return None
|
||||
|
||||
def _filter_group(name: str, titles: list[str], group: str) -> bool | None:
|
||||
for title in titles:
|
||||
if title in name:
|
||||
return "Examen" in name or group == "all" or group in name
|
||||
if title.upper() in name.upper():
|
||||
return group == "all" or group in name
|
||||
|
||||
return None
|
||||
|
||||
def _filter_event(name: str, td_group: str, sh_group: str) -> bool:
|
||||
res = _filter_group(name, td_titles, td_group)
|
||||
res = _filter_group(name, td_titles, td_group, td_groups)
|
||||
if res is not None:
|
||||
return res
|
||||
|
||||
if _filter_group(name, sh_titles, sh_group) == False:
|
||||
if _filter_group(name, sh_titles, sh_group, sh_groups) == False:
|
||||
return False
|
||||
|
||||
return True
|
||||
@@ -27,4 +38,4 @@ def filter_calendar(calendar: Calendar, td_group: str, sh_group: str) -> Calenda
|
||||
if _filter_event(event.name, td_group, sh_group):
|
||||
filtered_calendar.events.add(event)
|
||||
|
||||
return filtered_calendar
|
||||
return filtered_calendar
|
||||
Reference in New Issue
Block a user