Skip to content

Commit

Permalink
making the function more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
Exoutia committed Oct 4, 2022
1 parent 4e2c2b5 commit 69af369
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions f1pystats/driver_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ def __init__(self, info):

def get_drivers_names(self):
'''Returns the driver's name list'''
return [" ".join([i["givenName"], i["familyName"]]) for i in self.info]
return [" ".join([i["givenName"], i["familyName"]]) for i in self.info["MRData"]["DriverTable"]["Drivers"]]

def get_drivers_dob(self):
'''Returns the driver's date of birth list'''
return [i["dateOfBirth"] for i in self.info]
return [i["dateOfBirth"] for i in self.info["MRData"]["DriverTable"]["Drivers"]]

def get_drivers_nationality(self):
"""Returns the list of driver's nationality"""
return [i["nationality"] for i in self.info]
return [i["nationality"] for i in self.info["MRData"]["DriverTable"]["Drivers"]]

def get_drivers_number(self):
"""Returns the list of driver's number"""
return [i["permanentNumber"] for i in self.info]
return [i["permanentNumber"] for i in self.info["MRData"]["DriverTable"]["Drivers"]]

2 changes: 1 addition & 1 deletion f1pystats/f1pystats.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_drivers(year: int, round_num: int =None):
page = requests.get(link, timeout=15)

json_data = page.json()
driver_info_json = json_data["MRData"]["DriverTable"]["Drivers"]
driver_info_json = json_data
dr_info = DriverInfo(driver_info_json)

dr_name = dr_info.get_drivers_names()
Expand Down

0 comments on commit 69af369

Please sign in to comment.