From 6cfb5b9b21cb601dd8870ba0b5096b4caf6c7a15 Mon Sep 17 00:00:00 2001
From: Matthew Hague <Matthew.Hague@rhul.ac.uk>
Date: Thu, 6 Jun 2024 13:51:36 +0100
Subject: [PATCH] del(timetable): remove overlaps feature

---
 timetabling/README.md        |  2 +-
 timetabling/timetable-ics.py | 35 ++++++++++-------------------------
 2 files changed, 11 insertions(+), 26 deletions(-)

diff --git a/timetabling/README.md b/timetabling/README.md
index 4fcaef4..5cb09cb 100644
--- a/timetabling/README.md
+++ b/timetabling/README.md
@@ -1,5 +1,5 @@
 
 # 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. Also prints out overlaps spotted.
+* `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.
 * `get-practical-groups.py` -- find out which lab groups your students belong to on the web timetable.
diff --git a/timetabling/timetable-ics.py b/timetabling/timetable-ics.py
index de74268..edebaa1 100644
--- a/timetabling/timetable-ics.py
+++ b/timetabling/timetable-ics.py
@@ -16,14 +16,15 @@ if len(sys.argv) < 2:
 
 timetable_csv = sys.argv[1]
 
-cals = { year: Calendar() for year in range(0, 6) }
+cals = { str(year): Calendar() for year in range(0, 6) }
+cals.update({ "Bedford": Calendar() })
 
-def get_years(name : str) -> Generator[int, None, None]:
+def get_years(name : str) -> Generator[str, None, None]:
     # remove CS2900 assessment weird names
     name = re.sub(r"<[^<]*>", "", name)
     for sess in name.split(","):
         year = int(sess.strip()[2])
-        yield year
+        yield str(year)
 
 def get_weeks(weeks : str) -> Generator[int, None, None]:
     for period in weeks.split(","):
@@ -81,6 +82,10 @@ with open(timetable_csv) as f:
         duration_hours = row["Duration"]
         weeks = get_weeks(row["Teaching Week Pattern"])
 
+        location = ""
+        if "PROVISIONAL Location Name" in row:
+            location = row["PROVISIONAL Location Name"]
+
         if day is None:
             print("Could not find timetabled day column, aborting")
             exit()
@@ -105,30 +110,10 @@ with open(timetable_csv) as f:
                 event.end = end_time
                 for year in get_years(name):
                     cals[year].events.add(event)
+                if "bedford" in location.lower():
+                    cals["Bedford"].events.add(event)
 
 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(tuple(sorted([
-                    f"{event.name}@{event.begin.strftime('%a %H:%M')}",
-                    f"{overlap.name}@{overlap.begin.strftime('%a %H:%M')}"
-                ])))
-    for overlap in sorted(overlaps_full):
-        print("OVERLAP:")
-        for detail in overlap:
-            print(" ", detail)
-- 
GitLab