Implement fetching of certain data from OpenF1
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user