Skip to content

Commit

Permalink
Merge pull request #510 from cwendt94/feat-add-owner
Browse files Browse the repository at this point in the history
feat: Add full owner info to team
  • Loading branch information
cwendt94 authored Dec 5, 2023
2 parents 2ccb6b7 + 4edc1cd commit e74790d
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion espn_api/base_league.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ def _fetch_teams(self, data, TeamClass, pro_schedule = None):
teams = data['teams']
schedule = data['schedule']
seasonId = data['seasonId']
members = data.get('members', [])

team_roster = {}
for team in data['teams']:
team_roster[team['id']] = team.get('roster', {})

for team in teams:
roster = team_roster[team['id']]
self.teams.append(TeamClass(team, roster=roster, schedule=schedule, year=seasonId, pro_schedule=pro_schedule))
owners = [member for member in members if member.get('id') == team.get('owners', [''])[0]]
self.teams.append(TeamClass(team, roster=roster, schedule=schedule, year=seasonId, owners=owners, pro_schedule=pro_schedule))

# sort by team ID
self.teams = sorted(self.teams, key=lambda x: x.team_id, reverse=False)
Expand Down
2 changes: 1 addition & 1 deletion espn_api/baseball/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, data, roster, schedule, year, **kwargs):

self._fetch_roster(roster)
self._fetch_schedule(schedule)
self.owners = data.get('owners', [])
self.owners = kwargs.get('owners', [])

def __repr__(self):
return f'Team({self.team_name})'
Expand Down
2 changes: 1 addition & 1 deletion espn_api/basketball/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, data, roster, schedule, year, **kwargs):

self._fetch_roster(roster, year, kwargs.get('pro_schedule'))
self._fetch_schedule(schedule)
self.owners = data.get('owners', [])
self.owners = kwargs.get('owners', [])

def __repr__(self):
return f'Team({self.team_name})'
Expand Down
2 changes: 1 addition & 1 deletion espn_api/football/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, data, roster, schedule, year, **kwargs):
self.mov = []
self._fetch_schedule(schedule)
self._fetch_roster(roster, year)
self.owners = data.get('owners', [])
self.owners = kwargs.get('owners', [])

def __repr__(self):
return 'Team(%s)' % (self.team_name, )
Expand Down
2 changes: 1 addition & 1 deletion espn_api/hockey/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, data, roster, schedule, year, **kwargs):

self._fetch_roster(roster)
self._fetch_schedule(schedule)
self.owners = data.get('owners', [])
self.owners = kwargs.get('owners', [])

def __repr__(self):
return 'Team(%s)' % (self.team_name,)
Expand Down
2 changes: 1 addition & 1 deletion espn_api/wbasketball/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, data, roster, schedule, year, **kwargs):

self._fetch_roster(roster, year)
self._fetch_schedule(schedule)
self.owners = data.get('owners', [])
self.owners = kwargs.get('owners', [])

def __repr__(self):
return f'Team({self.team_name})'
Expand Down

0 comments on commit e74790d

Please sign in to comment.