Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add important dates feature #85

Merged
merged 21 commits into from
Apr 9, 2018

Conversation

trevor-viljoen
Copy link
Contributor

This PR adds #84. Example and sample output:

from __future__ import print_function
import mlbgame

important_dates = mlbgame.important_dates(2017)
print(important_dates)
Opening Day 2017: Sunday, April 02.
Last day of the 1st half: Sunday, July 09.
2017 All Star Game: Tuesday, July 11.
First day of the 2nd half: Friday, July 14.
Last day of the 2017 season: Sunday, October 01.
2017 Playoffs start: Tuesday, October 03.
2017 Playoffs end: Wednesday, November 01.

@panzarino
Copy link
Owner

@trevor-viljoen Great work! Could you please fix the pep8 issues as described in the codeclimate issue sbefore I merge?

@trevor-viljoen trevor-viljoen force-pushed the feature/important_dates branch from 3fbb388 to 8fc560a Compare April 1, 2018 17:29
Copy link
Contributor

@dowski dowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice feature! Hope you don't mind a drive-by review.

@@ -228,6 +228,12 @@ def game_events(game_id):
return [mlbgame.events.Inning(data[x], x) for x in data]


def important_dates(year=datetime.now().year):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using year=None here and then assigning year to datetime.now().year in the function body if None is passed in.

The way it's currently done the default value for year will be calculated at import time.

mlbgame/info.py Outdated
wildcard_teams
year
"""
def dtfmt(self, my_date):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slight simplification if you want: this can be a function in the module instead of a method on this class. Then you can just refer to it as dtfmt when calling it below instead of self.dtfmt.

mlbgame/info.py Outdated
return ''
return my_date.strftime('%A, %B %d')

def strformat(self, my_str, args):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar suggestion as above.

@panzarino
Copy link
Owner

@trevor-viljoen Looks good!

@panzarino panzarino merged commit 93a6482 into panzarino:master Apr 9, 2018
@trevor-viljoen trevor-viljoen deleted the feature/important_dates branch October 10, 2018 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants