Skip to content
Snippets Groups Projects
Commit 86a0da24 authored by Hague Matthew UXAC009's avatar Hague Matthew UXAC009
Browse files

add(timetabling): print overlaps found when processing

parent dbb3d2d2
Branches
No related tags found
No related merge requests found
# Timetabling Scripts
* `timetable-ics.py` -- convert the Timetabling team spreadsheets into ICS format. This is a rough and ready script and will probably need tweaks to your particular spreadsheet.
* `timetable-ics.py` -- convert the Timetabling team spreadsheets into ICS format. This is a rough and ready script and will probably need tweaks to your particular spreadsheet. Also prints out overlaps spotted.
......@@ -69,6 +69,9 @@ with open(timetable_csv) as f:
duration_hours = row["Duration"]
weeks = get_weeks(row["Teaching Week Pattern"])
if "TUT" in name:
continue
for week in weeks:
offset = get_day_offset(day)
if offset < 0:
......@@ -86,3 +89,26 @@ with open(timetable_csv) as f:
for year in cals:
with open(f"Year{year}.ics", 'w') as icsfile:
icsfile.writelines(cals[year].serialize_iter())
overlaps = set()
overlaps_full = set()
for event in cals[year].events:
event_overlaps = cals[year].timeline.overlapping(event.begin, event.end)
for overlap in event_overlaps:
true_over = \
overlap.uid != event.uid \
and event.begin != overlap.end \
and event.end != overlap.begin \
and "TUT" not in event.name \
and "TUT" not in overlap.name
overlap_entry = frozenset([event.name, overlap.name])
if true_over and overlap_entry not in overlaps:
overlaps.add(overlap_entry)
overlaps_full.add(frozenset([
f"{event.name}@{event.begin.strftime('%a %H:%M')}",
f"{overlap.name}@{overlap.begin.strftime('%a %H:%M')}"
]))
for overlap in overlaps_full:
print("OVERLAP:")
for detail in overlap:
print(" ", detail)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment