paper-dynasty-card-creation/scripts/legacy/fix_pitcher_errors.py
Cal Corum 0a17745389 Run black and ruff across entire codebase
Standardize formatting with black and apply ruff auto-fixes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 14:24:33 -05:00

33 lines
960 B
Python

import asyncio
import sys
from creation_helpers import pd_players_df
from db_calls import db_post
from defenders.calcs_defense import get_bbref_fielding_df
from pitchers.creation import create_position
async def main(args):
all_cardsets = [(2008, 12), (2013, 6), (2022, 3), (2023, 9)]
# all_cardsets = [(2008, 12)]
for year, cardset_id in all_cardsets:
print(f"Running {year} now...")
all_players = await pd_players_df(cardset_id)
df_p = get_bbref_fielding_df("p", year)
pitcher_df = all_players.merge(df_p, left_on="bbref_id", right_on="key_bbref")
await create_position(
season_pct=1.00, pitching_stats=pitcher_df, post_pitchers=True, df_p=df_p
)
print("Resetting images...")
pitcher_ids = pitcher_df["player_id"]
for x in pitcher_ids:
await db_post(f"players/{x}/image-reset")
if __name__ == "__main__":
asyncio.run(main(sys.argv[1:]))