Skip to content

Commit

Permalink
Resolve errors while pulling empty NBA stats pages
Browse files Browse the repository at this point in the history
Some players don't have a personal stats page created for them yet, but
contain a valid link on roster pages. As implemented, the Roster module
for the NBA does not check if the returned data from the page is empty,
and will attempt to parse information from an object which is None.
Instead, if a player's page is invalid, the module should fail-fast and
return None for the player instead of attempting to parse information or
handle other scenarios.

Signed-Off-By: Robert Clark <robdclark@outlook.com>
  • Loading branch information
roclark committed Oct 4, 2019
1 parent 51df345 commit 1bea117
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sportsreference/nba/roster.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ def __init__(self, player_id):
self._contract = None

player_data = self._pull_player_data()
if not player_data:
return
self._find_initial_index()
AbstractPlayer.__init__(self, player_id, self._name, player_data)

Expand Down Expand Up @@ -484,6 +486,8 @@ def _pull_player_data(self):
stats.
"""
player_info = self._retrieve_html_page()
if not player_info:
return
self._parse_player_information(player_info)
self._parse_nationality(player_info)
self._parse_birth_date(player_info)
Expand Down

0 comments on commit 1bea117

Please sign in to comment.