Skip to content

Commit

Permalink
More for #68
Browse files Browse the repository at this point in the history
- _search_schedule returns a single game if eid is matched
- live.py now has a method for returning _cur_season_phase
  • Loading branch information
derek-adair committed Aug 23, 2019
1 parent dfe4874 commit 53e6137
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions nflgame/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,9 @@ def _search_schedule(year=None, week=None, home=None, away=None, kind='REG',
for info in nflgame.sched.games.values():
y, t, w = info['year'], info['season_type'], info['week']
h, a = info['home'], info['away']
if eid is not None and eid != info['eid']:
continue
if eid is not None and eid == info['eid']:
# Always return a non-array if eid is a match
return info
if year is not None:
if isinstance(year, list) and y not in year:
continue
Expand Down
3 changes: 0 additions & 3 deletions nflgame/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,6 @@ def __new__(cls, eid=None, fpath=None, **kwargs):
if len(kwargs) == 0:
return None

# Flatten the search results
kwargs = kwargs[0]

gameData = {
'home': {
'abbr': kwargs['home'],
Expand Down
5 changes: 5 additions & 0 deletions nflgame/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@
"""


def current_season_phase():
_update_week_number()
return _cur_season_phase

def current_year_and_week():
"""
Returns a tuple (year, week) where year is the current year of the season
Expand Down Expand Up @@ -215,6 +219,7 @@ def run(callback, active_interval=15, inactive_interval=900, stop=None):
last_week_check = _update_week_number()

games = _active_games(inactive_interval)

if active:
active = _run_active(callback, games)
if not active:
Expand Down

0 comments on commit 53e6137

Please sign in to comment.