From 775108e9a916f790b53aed4111f29094b1b3f144 Mon Sep 17 00:00:00 2001 From: "Randall \"Randy\" Forbes" Date: Wed, 28 Aug 2024 09:26:09 -0400 Subject: [PATCH] Fixed error where wnba_teams was not present in the data.py file after update. (#463) * Added wnba_teams to the template used in generating the static output for data.py * updated release version and changelog. --- CHANGELOG.MD | 6 ++++++ pyproject.toml | 2 +- src/nba_api/stats/library/data.py | 15 +++++++++++++++ tools/stats/static_players_update/template.py | 15 +++++++++++++++ tools/stats/static_players_update/update.py | 10 +++++++--- 5 files changed, 44 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 612586e..9ce9309 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -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 diff --git a/pyproject.toml b/pyproject.toml index e657728..8882940 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = [ diff --git a/src/nba_api/stats/library/data.py b/src/nba_api/stats/library/data.py index 952aaa1..3d40700 100644 --- a/src/nba_api/stats/library/data.py +++ b/src/nba_api/stats/library/data.py @@ -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", []], +] diff --git a/tools/stats/static_players_update/template.py b/tools/stats/static_players_update/template.py index 1ffe69d..3c7c26b 100644 --- a/tools/stats/static_players_update/template.py +++ b/tools/stats/static_players_update/template.py @@ -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 = ( diff --git a/tools/stats/static_players_update/update.py b/tools/stats/static_players_update/update.py index 8942d2c..a7bc6d3 100644 --- a/tools/stats/static_players_update/update.py +++ b/tools/stats/static_players_update/update.py @@ -1,4 +1,5 @@ import os +import shutil from datetime import datetime from nba_api.stats.endpoints.commonallplayers import CommonAllPlayers @@ -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"): @@ -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__":