Skip to content
Snippets Groups Projects
Commit 7ea87beb authored by Lennard Geese's avatar Lennard Geese
Browse files

Fix error with html-find() returning None

parent 56643540
No related branches found
No related tags found
No related merge requests found
...@@ -131,8 +131,10 @@ class DataAnalyser(DataHandler): ...@@ -131,8 +131,10 @@ class DataAnalyser(DataHandler):
header = tableRow.find("th") header = tableRow.find("th")
if header is None: continue if header is None: continue
if header.string == "Weather": if header.string == "Weather":
weatherRaw = tableRow.find("td").string weatherEntry = tableRow.find("td")
return re.sub("\n", "", tableRow.find("td").string) 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") raise KeyError("No weather entry found")
......
...@@ -35,6 +35,7 @@ class DataImporter(DataHandler, ABC): ...@@ -35,6 +35,7 @@ class DataImporter(DataHandler, ABC):
weatherEntries: list[string] = [] weatherEntries: list[string] = []
for e in event: for e in event:
weatherEntries.append(self.fetchWeather(e)) weatherEntries.append(self.fetchWeather(e))
return weatherEntries
# Convert from SessionIdentifier to Event if needed # Convert from SessionIdentifier to Event if needed
if isinstance(event, SessionIdentifier): if isinstance(event, SessionIdentifier):
......
...@@ -17,6 +17,13 @@ class Main: ...@@ -17,6 +17,13 @@ class Main:
plotter = DataPlotter() plotter = DataPlotter()
checker = DataChecker() 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): def main(self):
#dataHandler = Main.DataHandlingPackage() #dataHandler = Main.DataHandlingPackage()
...@@ -26,21 +33,15 @@ class Main: ...@@ -26,21 +33,15 @@ class Main:
#self.printRainRaces() #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) #self.overtakeAnalysis(racesToAnalyse)
def testNewRainRaceFetching(self): def testNewRainRaceFetching(self):
dataHandler: Main.DataHandlingPackage = Main.DataHandlingPackage() dataHandler: Main.DataHandlingPackage = Main.DataHandlingPackage()
sessionIdentifier: SessionIdentifier = SessionIdentifier(2024, "Brazil", "R") weather = dataHandler.importer.fetchWeather(self.racesToAnalyse)
weather = dataHandler.importer.fetchWeather(sessionIdentifier)
print(weather) print(weather)
def printRainRaces(self): def printRainRaces(self):
dataHandler: Main.DataHandlingPackage = Main.DataHandlingPackage() dataHandler: Main.DataHandlingPackage = Main.DataHandlingPackage()
year: int = 2015 year: int = 2015
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment