Implement fetching of certain data from OpenF1

This commit is contained in:
2024-03-10 19:54:28 +01:00
parent c2838c3332
commit 1ab92eff9a
5 changed files with 115 additions and 3 deletions

View File

@ -11,7 +11,10 @@ class ApiPosition():
"position": int
}
def __init__(self, response: dict[str, str]):
def __init__(self, response: dict[str, str] | None):
if response is None:
return
for key in response:
if not hasattr(self, key):
raise Exception(f"Mismatch between response data and {type(self).__name__} (key={key})")
@ -23,6 +26,13 @@ class ApiPosition():
print("ApiPosition:", self.__dict__)
def to_params(self) -> Dict[str, str]:
params: Dict[str, str] = dict()
for key in self.__dict__:
params[str(key)] = str(self.__dict__[key])
return params
session_key: int = None # type: ignore
meeting_key: int = None # type: ignore
driver_number: int = None # type: ignore