Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
F1 Overtake Analyser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lennard Geese
F1 Overtake Analyser
Commits
56643540
Commit
56643540
authored
2 weeks ago
by
Lennard Geese
Browse files
Options
Downloads
Patches
Plain Diff
Adjust fetchWeather for lists of multiple events
parent
51ee533f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
DataImporter.py
+15
-6
15 additions, 6 deletions
DataImporter.py
main.py
+1
-1
1 addition, 1 deletion
main.py
with
16 additions
and
7 deletions
DataImporter.py
+
15
−
6
View file @
56643540
...
...
@@ -7,6 +7,7 @@ from abc import ABC
import
requests
from
fastf1.core
import
Session
from
fastf1.ergast
import
fetch_day
from
fastf1.events
import
EventSchedule
,
Event
from
DataAnalyser
import
DataAnalyser
...
...
@@ -21,17 +22,25 @@ class DataImporter(DataHandler, ABC):
sessions. If the method does not require one of these, it should not be part of this class.
"""
def
fetchEventWeather
(
self
,
event
:
Event
|
SessionIdentifier
):
def
fetchWeather
(
self
,
event
:
Event
|
SessionIdentifier
|
list
[
Event
]
|
list
[
SessionIdentifier
]):
"""
Fetch session weather from the wikipedia entry for the specified event.
:param event: The event or identifier for any session of the event to fetch weather for.
:return: Weather conditions as string
Fetch session weather from the wikipedia entry for the specified event(s).
:param event: The event or identifier for any session of the event to fetch weather for. Alternatively a list of
these.
:return: Weather conditions as string, or a list of such strings if a list is provided.
"""
# Recursive call if list provided
if
isinstance
(
event
,
list
):
weatherEntries
:
list
[
string
]
=
[]
for
e
in
event
:
weatherEntries
.
append
(
self
.
fetchWeather
(
e
))
# Convert from SessionIdentifier to Event if needed
if
isinstance
(
event
,
SessionIdentifier
):
event
=
self
.
importEvent
(
event
.
year
,
event
.
event
)
# Fetch weather
wikiHtml
=
self
.
__importWikiHtml
(
event
)
analyser
=
DataAnalyser
()
weather
=
analyser
.
extractWeatherFromHtml
(
wikiHtml
)
...
...
This diff is collapsed.
Click to expand it.
main.py
+
1
−
1
View file @
56643540
...
...
@@ -37,7 +37,7 @@ class Main:
def
testNewRainRaceFetching
(
self
):
dataHandler
:
Main
.
DataHandlingPackage
=
Main
.
DataHandlingPackage
()
sessionIdentifier
:
SessionIdentifier
=
SessionIdentifier
(
2024
,
"
Brazil
"
,
"
R
"
)
weather
=
dataHandler
.
importer
.
fetch
Event
Weather
(
sessionIdentifier
)
weather
=
dataHandler
.
importer
.
fetchWeather
(
sessionIdentifier
)
print
(
weather
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment