diff --git a/DataAnalyser.py b/DataAnalyser.py index 781a60f68f0717ea38cc35aaaff972275be80617..1ff857a11bd0d6ff01c6cd1f61931158b81b93f9 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 56061fe6370d90464af82beda5579d74c7ff7605..6220d4c48908b0a93aefced55c6930915a29aa0c 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 78c1f25513874a7a220b3e6b4b8ad1cc391911ae..074931c70099a20b571572047845dbed8045f821 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