sportsstats package

Submodules

sportsstats.nba module

nba

Download NBA statistics from: http://stats.nba.com/tracking/

exception sportsstats.nba.DownloadError[source]

Bases: exceptions.Exception

class sportsstats.nba.Stats(start, end)[source]

NBA Statistics.

Attributes:
start (datetime): The start date for the statistics to download. end (datetime): The end date for the statistics to download.
download()[source]

Download NBA statistics.

Returns:
The requested statistics as JSON bytes.

sportsstats.utils module

utils

Utilities used in sportsstats

sportsstats.utils.add_years(dt, years)[source]

Add (or subtract) years, handling leap years.

Args:
dt (datetime): The datetime object. years (int): Positive or negative number of years to add.
Returns:
datetime: The same calendar date (month and day) in the
destination year, if it exists, otherwise use the following day (thus changing February 29 to March 1).
sportsstats.utils.beautify_json(content)[source]

Parse JSON string and make it more human readable.

Args:
content (str): UTF-8 encoded JSON.
Returns:
str: Human readable JSON
sportsstats.utils.unique_filepath(path)[source]

Get a unique, absolute filepath from path by appending _%d, where %d is a unique digit starting at 1.

Args:
path (str): A not necessarily absolute filepath.
Returns:
str: A unique, absolute filepath.

Module contents