From 7ea87beb48899278db19d724052bbfde8257dcd3 Mon Sep 17 00:00:00 2001
From: Lennard Geese <lennard.geese@sva.de>
Date: Wed, 16 Apr 2025 17:01:19 +0200
Subject: [PATCH] Fix error with html-find() returning None

---
 DataAnalyser.py |  6 ++++--
 DataImporter.py |  1 +
 main.py         | 17 +++++++++--------
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/DataAnalyser.py b/DataAnalyser.py
index 781a60f..1ff857a 100644
--- a/DataAnalyser.py
+++ b/DataAnalyser.py
@@ -131,8 +131,10 @@ class DataAnalyser(DataHandler):
             header = tableRow.find("th")
             if header is None: continue
             if header.string == "Weather":
-                weatherRaw = tableRow.find("td").string
-                return re.sub("\n", "", tableRow.find("td").string)
+                weatherEntry = tableRow.find("td")
+                weatherString = tableRow.find("td").string
+                if weatherString is None: weatherString = weatherEntry.contents[0].string # needed if entry contains more tags
+                return re.sub("\n", "", weatherString)
 
         raise KeyError("No weather entry found")
 
diff --git a/DataImporter.py b/DataImporter.py
index 56061fe..6220d4c 100644
--- a/DataImporter.py
+++ b/DataImporter.py
@@ -35,6 +35,7 @@ class DataImporter(DataHandler, ABC):
             weatherEntries: list[string] = []
             for e in event:
                 weatherEntries.append(self.fetchWeather(e))
+            return weatherEntries
 
         # Convert from SessionIdentifier to Event if needed
         if isinstance(event, SessionIdentifier):
diff --git a/main.py b/main.py
index 78c1f25..074931c 100644
--- a/main.py
+++ b/main.py
@@ -17,6 +17,13 @@ class Main:
         plotter = DataPlotter()
         checker = DataChecker()
 
+    racesToAnalyse = [
+        SessionIdentifier(2022, "Imola", "R"),  # Imola 2022 (DWR)
+        SessionIdentifier(2024, "Imola", "R"),  # Imola 2024 (SWR)
+        SessionIdentifier(2024, "Montreal", "R"),  # Canada 2024 (DWR)
+        SessionIdentifier(2023, "Montreal", "R")  # Canada 2023 (SWR)
+    ]
+
     def main(self):
 
         #dataHandler = Main.DataHandlingPackage()
@@ -26,21 +33,15 @@ class Main:
 
         #self.printRainRaces()
 
-        racesToAnalyse = [
-            SessionIdentifier(2022, "Imola", "R"),      # Imola 2022 (DWR)
-            SessionIdentifier(2024, "Imola", "R"),      # Imola 2024 (SWR)
-            SessionIdentifier(2024, "Montreal", "R"),   # Canada 2024 (DWR)
-            SessionIdentifier(2023, "Montreal", "R")    # Canada 2023 (SWR)
-        ]
         #self.overtakeAnalysis(racesToAnalyse)
 
     def testNewRainRaceFetching(self):
         dataHandler: Main.DataHandlingPackage = Main.DataHandlingPackage()
-        sessionIdentifier: SessionIdentifier = SessionIdentifier(2024, "Brazil", "R")
-        weather = dataHandler.importer.fetchWeather(sessionIdentifier)
+        weather = dataHandler.importer.fetchWeather(self.racesToAnalyse)
         print(weather)
 
 
+
     def printRainRaces(self):
         dataHandler: Main.DataHandlingPackage = Main.DataHandlingPackage()
         year: int = 2015
-- 
GitLab