Skip to content

Commit

Permalink
Fix pep8 styling
Browse files Browse the repository at this point in the history
  • Loading branch information
panzarino committed Aug 24, 2017
1 parent bb39c6b commit c5c1be0
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 29 deletions.
2 changes: 1 addition & 1 deletion mlbgame/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def roster(team_id):

def standings(date=datetime.now()):
"""Return Standings object that contains standings info
date should be a datetime object,
leave empty to get current standings
"""
Expand Down
6 changes: 3 additions & 3 deletions mlbgame/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ def game_events(game_id):

class Inning(object):
"""Class that holds at bats in an inning.
Properties:
bottom
num
top
"""

def __init__(self, data, inning):
"""Creates an inning object that matches the corresponding
info in `data`.
`data` should be a dictionary of values.
"""
self.num = int(inning)
Expand Down
29 changes: 16 additions & 13 deletions mlbgame/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def scoreboard(year, month, day, home=None, away=None):

class GameScoreboard(object):
"""Object to hold scoreboard information about a certain game.
Properties:
away_team
away_team_errors
Expand Down Expand Up @@ -211,7 +211,7 @@ def __init__(self, data):
minute = other[:2]
am_pm = other[2:]
if am_pm == 'PM':
hour = int(hour)+11
hour = int(hour) + 11
self.date = datetime.datetime(int(year), int(month), int(day),
int(hour), int(minute))

Expand Down Expand Up @@ -245,7 +245,7 @@ def box_score(game_id):

class GameBoxScore(object):
"""Object to hold the box score of a certain game.
Properties:
game_id
innings:
Expand Down Expand Up @@ -300,22 +300,22 @@ def print_scoreboard(self):
# that looks like a scoreboard
output += 'Inning\t'
for x in innings:
output += str(x)+' '
output += str(x) + ' '
output += '\n'
for x in innings:
output += '---'
output += '\nAway\t'
for y, x in enumerate(away, start=1):
if y >= 10:
output += str(x)+' '
output += str(x) + ' '
else:
output += str(x)+' '
output += str(x) + ' '
output += '\nHome\t'
for y, x in enumerate(home, start=1):
if y >= 10:
output += str(x)+' '
output += str(x) + ' '
else:
output += str(x)+' '
output += str(x) + ' '
return output


Expand Down Expand Up @@ -475,7 +475,7 @@ def players(game_id):

class Players(object):
"""Object to hold player/coach/umpire information for a game.
Properties:
away_coaches
away_players
Expand All @@ -496,9 +496,10 @@ def __init__(self, data):
self.away_coaches = [Coach(x) for x in data['away_team']['coaches']]
self.umpires = [Umpire(x) for x in data['umpires']]


class Player(mlbgame.object.Object):
"""Object to hold player information
Properties:
avg
bats
Expand All @@ -523,9 +524,10 @@ class Player(mlbgame.object.Object):
"""
pass


class Coach(mlbgame.object.Object):
"""Object to hold coach information
Properties:
first
id
Expand All @@ -535,14 +537,15 @@ class Coach(mlbgame.object.Object):
"""
pass


class Umpire(mlbgame.object.Object):
"""Object to hold umpire information
Properties:
first
id
last
name
position
"""
pass
pass
21 changes: 13 additions & 8 deletions mlbgame/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,13 @@ def __init__(self, date):
now = datetime.now()
if date.year == now.year and date.month == now.month and date.day == now.day:
self.standings_url = ('http://mlb.mlb.com/lookup/json/named.standings_schedule_date.bam?season=%s&'
'schedule_game_date.game_date=%%27%s%%27&sit_code=%%27h0%%27&league_id=103&'
'league_id=104&all_star_sw=%%27N%%27&version=2') % (date.year, date.strftime('%Y/%m/%d'))
'schedule_game_date.game_date=%%27%s%%27&sit_code=%%27h0%%27&league_id=103&'
'league_id=104&all_star_sw=%%27N%%27&version=2') % (date.year, date.strftime('%Y/%m/%d'))
self.standings_schedule_date = 'standings_schedule_date'
else:
self.standings_url = ('http://mlb.mlb.com/lookup/json/named.historical_standings_schedule_date.bam?season=%s&'
'game_date=%%27%s%%27&sit_code=%%27h0%%27&league_id=103&'
'league_id=104&all_star_sw=%%27N%%27&version=48') % (date.year, date.strftime('%Y/%m/%d'))
'game_date=%%27%s%%27&sit_code=%%27h0%%27&league_id=103&'
'league_id=104&all_star_sw=%%27N%%27&version=48') % (date.year, date.strftime('%Y/%m/%d'))
self.standings_schedule_date = 'historical_standings_schedule_date'
self.divisions = []
self.parse_standings()
Expand All @@ -269,7 +269,8 @@ def standings_json(self):
def set_last_update(self):
"""Return a dateutil object from string [last update]
originally in ISO 8601 format: YYYY-mm-ddTHH:MM:SS"""
last_update = self.standings_json[self.standings_schedule_date]['standings_all_date_rptr']['standings_all_date'][0]['queryResults']['created']
last_update = self.standings_json[self.standings_schedule_date][
'standings_all_date_rptr']['standings_all_date'][0]['queryResults']['created']
return dateutil.parser.parse(last_update)

def parse_standings(self):
Expand All @@ -283,14 +284,16 @@ def parse_standings(self):
else:
# Raise Error
try:
raise UnknownLeagueID('An unknown `league_id` was passed from standings json.')
raise UnknownLeagueID(
'An unknown `league_id` was passed from standings json.')
except UnknownLeagueID as e:
print('StandingsError: %s' % e)
raise
sys.exit(-1)

for division in divisions:
teams = [team for team in league['queryResults']['row'] if team['division_id'] == division]
teams = [team for team in league['queryResults']
['row'] if team['division_id'] == division]
mlbdiv = Division(divisions[division], teams)
self.divisions.append(mlbdiv)

Expand All @@ -310,6 +313,7 @@ class Division(object):
name
teams
"""

def __init__(self, name, teams):
self.name = name
self.teams = []
Expand Down Expand Up @@ -420,7 +424,8 @@ def set_last_update(self):
def parse_injury(self):
"""Parse the json injury"""
injuries = self.injury_json['wsfb_news_injury']['queryResults']['row']
injuries = [injury for injury in injuries if injury['team_id'] == self.team_id]
injuries = [
injury for injury in injuries if injury['team_id'] == self.team_id]
for injury in injuries:
mlbinjury = Injury(injury)
self.injuries.append(mlbinjury)
Expand Down
8 changes: 4 additions & 4 deletions mlbgame/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,23 @@ def team_stats(game_id):

class Stats(object):
"""Hold stats information for a game.
Properties:
away_batting
away_pitching
game_id
home_batting
home_pitching
"""

def __init__(self, data, game_id, player):
"""Creates a players object that matches the corresponding info in `data`.
`data` should be an dictionary of values.
'game_id' should be the id for the game.
"""
self.game_id = game_id
output = {'home_pitching': [], 'away_pitching': [], 'home_batting': [],
'away_batting': []}
'away_batting': []}
for y in data:
# create objects for all data
if player:
Expand Down Expand Up @@ -226,7 +226,7 @@ def __str__(self):

class TeamStats(mlbgame.object.Object):
"""Holds total pitching or batting stats for a team.
Properties:
Batting:
ab
Expand Down

0 comments on commit c5c1be0

Please sign in to comment.