Skip to content

Commit

Permalink
Fixed error where wnba_teams was not present in the data.py file afte…
Browse files Browse the repository at this point in the history
…r update. (#463)

* Added wnba_teams to the template used in generating the static output for data.py

* updated release version and changelog.
  • Loading branch information
rsforbes authored Aug 28, 2024
1 parent 2e68f50 commit 775108e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
- `Contributor` (notes on updates to the project)

# Version History
## v1.5.2
Date: 2024.08.28

### Fixed
* Fixed static data.py file where wnba_teams was missing.

## v1.5.1
Date: 2024.08.27

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "nba_api"
version = "1.5.1"
version = "1.5.2"
description = "An API Client package to access the APIs for NBA.com"
license = "MIT"
authors = [
Expand Down
15 changes: 15 additions & 0 deletions src/nba_api/stats/library/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6172,3 +6172,18 @@
[1610612765, 'DET', 'Pistons', 1948, 'Detroit', 'Detroit Pistons', 'Michigan', [1989, 1990, 2004]],
[1610612766, 'CHA', 'Hornets', 1988, 'Charlotte', 'Charlotte Hornets', 'North Carolina', []]
]

wnba_teams = [
[1611661313, "NYL", "Liberty", 1997, "New York", "New York Liberty", "New York", []],
[1611661317, "PHO", "Mercury", 1997, "Phoenix", "Phoenix Mercury", "Arizona", [2007, 2009, 2014]],
[1611661319, "LVA", "Aces", 1997, "Las Vegas", "Las Vegas Aces", "Nevada", [2022, 2023]],
[1611661320, "LAS", "Sparks", 1997, "Los Angeles", "Los Angeles Sparks", "California", [2001, 2002, 2016]],
[1611661321, "DAL", "Wings", 1998, "Dallas", "Dallas Wings", "Texas", [2003, 2006, 2008]],
[1611661322, "WAS", "Mystics", 1998, "Washington", "Washington Mystics", "District of Columbia", [2019]],
[1611661323, "CON", "Sun", 1999, "Connecticut", "Connecticut Sun", "Connecticut", []],
[1611661324, "MIN", "Lynx", 1999, "Minnesota", "Minnesota Lynx", "Minnesota", [2011, 2013, 2015, 2017]],
[1611661325, "IND", "Fever", 2000, "Indiana", "Indiana Fever", "Indiana", [2012]],
[1611661328, "SEA", "Storm", 2000, "Seattle", "Seattle Storm", "Washington",[2004, 2010, 2018, 2020]],
[1611661329, "CHI", "Sky", 2005, "Chicago", "Chicago Sky", "Illinois", [2021]],
[1611661330, "ATL", "Dream", 2008, "Atlanta", "Atlanta Dream", "Georgia", []],
]
15 changes: 15 additions & 0 deletions tools/stats/static_players_update/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@
[1610612765, 'DET', 'Pistons', 1948, 'Detroit', 'Detroit Pistons', 'Michigan', [1989, 1990, 2004]],
[1610612766, 'CHA', 'Hornets', 1988, 'Charlotte', 'Charlotte Hornets', 'North Carolina', []]
]
wnba_teams = [
[1611661313, "NYL", "Liberty", 1997, "New York", "New York Liberty", "New York", []],
[1611661317, "PHO", "Mercury", 1997, "Phoenix", "Phoenix Mercury", "Arizona", [2007, 2009, 2014]],
[1611661319, "LVA", "Aces", 1997, "Las Vegas", "Las Vegas Aces", "Nevada", [2022, 2023]],
[1611661320, "LAS", "Sparks", 1997, "Los Angeles", "Los Angeles Sparks", "California", [2001, 2002, 2016]],
[1611661321, "DAL", "Wings", 1998, "Dallas", "Dallas Wings", "Texas", [2003, 2006, 2008]],
[1611661322, "WAS", "Mystics", 1998, "Washington", "Washington Mystics", "District of Columbia", [2019]],
[1611661323, "CON", "Sun", 1999, "Connecticut", "Connecticut Sun", "Connecticut", []],
[1611661324, "MIN", "Lynx", 1999, "Minnesota", "Minnesota Lynx", "Minnesota", [2011, 2013, 2015, 2017]],
[1611661325, "IND", "Fever", 2000, "Indiana", "Indiana Fever", "Indiana", [2012]],
[1611661328, "SEA", "Storm", 2000, "Seattle", "Seattle Storm", "Washington",[2004, 2010, 2018, 2020]],
[1611661329, "CHI", "Sky", 2005, "Chicago", "Chicago Sky", "Illinois", [2021]],
[1611661330, "ATL", "Dream", 2008, "Atlanta", "Atlanta Dream", "Georgia", []],
]
"""

player_row_template = (
Expand Down
10 changes: 7 additions & 3 deletions tools/stats/static_players_update/update.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import shutil
from datetime import datetime

from nba_api.stats.endpoints.commonallplayers import CommonAllPlayers
Expand Down Expand Up @@ -61,13 +62,14 @@ def format_player_string(players_list):
return players_string.rstrip(",\n")


def write_static_data_file(directory, file_contents):
def write_static_data_file(directory, file_contents) -> str:
if not os.path.exists(directory):
os.makedirs(directory)
file_name = "data.py"
f = open(os.path.join(os.getcwd(), directory, file_name), "w")
f = open(file_path := os.path.join(os.getcwd(), directory, file_name), "w")
f.write(file_contents)
f.close()
return file_path


def generate_static_data_file(directory="static_files"):
Expand All @@ -87,7 +89,9 @@ def generate_static_data_file(directory="static_files"):
date_updated=datetime.now().strftime("%b, %d %Y"),
)

write_static_data_file(directory, file_contents)
src_file_path = write_static_data_file(directory, file_contents)

shutil.copyfile(src_file_path, 'src/nba_api/stats/library/data.py')


if __name__ == "__main__":
Expand Down

0 comments on commit 775108e

Please sign in to comment.