This commit is contained in:
Claude 2026-03-23 03:53:10 +00:00
commit f485241dd7
3 changed files with 25 additions and 33 deletions

View File

@ -595,21 +595,21 @@ def legal_splits(tot_chances):
def result_string(tba_data, row_num, split_min=None, split_max=None):
bold1 = f'{"<b>" if tba_data["bold"] else ""}'
bold2 = f'{"</b>" if tba_data["bold"] else ""}'
row_string = f'{"<b> </b>" if int(row_num) < 10 else ""}{row_num}'
bold1 = f"{'<b>' if tba_data['bold'] else ''}"
bold2 = f"{'</b>' if tba_data['bold'] else ''}"
row_string = f"{'<b> </b>' if int(row_num) < 10 else ''}{row_num}"
if TESTING:
print(
f'adding {tba_data["string"]} to row {row_num} / '
f"adding {tba_data['string']} to row {row_num} / "
f"split_min: {split_min} / split_max: {split_max}"
)
# No splits; standard result
if not split_min:
return f'{bold1}{row_string}-{tba_data["string"]}{bold2}'
return f"{bold1}{row_string}-{tba_data['string']}{bold2}"
# With splits
split_nums = f'{split_min if split_min != 20 else ""}{"-" if split_min != 20 else ""}{split_max}'
split_nums = f"{split_min if split_min != 20 else ''}{'-' if split_min != 20 else ''}{split_max}"
data_string = (
tba_data["sm-string"] if "sm-string" in tba_data.keys() else tba_data["string"]
)
@ -638,41 +638,39 @@ def result_string(tba_data, row_num, split_min=None, split_max=None):
row_output = "<b> </b>"
if TESTING:
print(f"row_output: {row_output}")
return f'{bold1}{row_output}{data_string}{" " * spaces}{split_nums}{bold2}'
return f"{bold1}{row_output}{data_string}{' ' * spaces}{split_nums}{bold2}"
def result_data(
tba_data, row_num, tba_data_bottom=None, top_split_max=None, fatigue=False
):
ret_data = {}
top_bold1 = f'{"<b>" if tba_data["bold"] else ""}'
top_bold2 = f'{"</b>" if tba_data["bold"] else ""}'
top_bold1 = f"{'<b>' if tba_data['bold'] else ''}"
top_bold2 = f"{'</b>' if tba_data['bold'] else ''}"
bot_bold1 = None
bot_bold2 = None
if tba_data_bottom:
bot_bold1 = f'{"<b>" if tba_data_bottom["bold"] else ""}'
bot_bold2 = f'{"</b>" if tba_data_bottom["bold"] else ""}'
bot_bold1 = f"{'<b>' if tba_data_bottom['bold'] else ''}"
bot_bold2 = f"{'</b>' if tba_data_bottom['bold'] else ''}"
if tba_data_bottom is None:
ret_data["2d6"] = f"{top_bold1}{int(row_num)}-{top_bold2}"
ret_data["splits"] = f"{top_bold1}{top_bold2}"
ret_data["result"] = (
f"{top_bold1}"
f'{tba_data["string"]}{"" if fatigue else ""}'
f"{top_bold2}"
f"{top_bold1}{tba_data['string']}{'' if fatigue else ''}{top_bold2}"
)
else:
ret_data["2d6"] = f"{top_bold1}{int(row_num)}-{top_bold2}\n"
ret_data["splits"] = (
f'{top_bold1}1{"-" if top_split_max != 1 else ""}'
f'{top_split_max if top_split_max != 1 else ""}{top_bold2}\n'
f'{bot_bold1}{top_split_max+1}{"-20" if top_split_max != 19 else ""}{bot_bold2}'
f"{top_bold1}1{'-' if top_split_max != 1 else ''}"
f"{top_split_max if top_split_max != 1 else ''}{top_bold2}\n"
f"{bot_bold1}{top_split_max + 1}{'-20' if top_split_max != 19 else ''}{bot_bold2}"
)
ret_data["result"] = (
f'{top_bold1}{tba_data["sm-string"] if "sm-string" in tba_data.keys() else tba_data["string"]}'
f"{top_bold1}{tba_data['sm-string'] if 'sm-string' in tba_data.keys() else tba_data['string']}"
f"{top_bold2}\n"
f"{bot_bold1}"
f'{tba_data_bottom["sm-string"] if "sm-string" in tba_data_bottom.keys() else tba_data_bottom["string"]}'
f"{tba_data_bottom['sm-string'] if 'sm-string' in tba_data_bottom.keys() else tba_data_bottom['string']}"
f"{bot_bold2}"
)
@ -688,9 +686,9 @@ def get_of(batter_hand, pitcher_hand, pull_side=True):
if batter_hand == "S":
if pitcher_hand == "L":
return "rf" if pull_side else "rf"
return "lf" if pull_side else "rf"
else:
return "lf" if pull_side else "lf"
return "rf" if pull_side else "lf"
def get_col(col_num):
@ -729,7 +727,7 @@ def get_position_string(all_pos: list, inc_p: bool):
for x in all_pos:
if x.position == "OF":
of_arm = f'{"+" if "-" not in x.arm else ""}{x.arm}'
of_arm = f"{'+' if '-' not in x.arm else ''}{x.arm}"
of_error = x.error
of_innings = x.innings
elif x.position == "CF":
@ -744,7 +742,7 @@ def get_position_string(all_pos: list, inc_p: bool):
elif x.position == "C":
all_def.append(
(
f'c-{x.range}({"+" if int(x.arm) >= 0 else ""}{x.arm}) e{x.error} T-{x.overthrow}(pb-{x.pb})',
f"c-{x.range}({'+' if int(x.arm) >= 0 else ''}{x.arm}) e{x.error} T-{x.overthrow}(pb-{x.pb})",
x.innings,
)
)
@ -1079,7 +1077,7 @@ def mlbteam_and_franchise(mlbam_playerid):
p_data["franchise"] = normalize_franchise(data["currentTeam"]["name"])
else:
logger.error(
f'Could not set team for {mlbam_playerid}; received {data["currentTeam"]["name"]}'
f"Could not set team for {mlbam_playerid}; received {data['currentTeam']['name']}"
)
else:
logger.error(
@ -1222,5 +1220,5 @@ def get_hand(df_data):
else:
return "R"
except Exception:
logger.error(f'Error in get_hand for {df_data["Name"]}')
logger.error(f"Error in get_hand for {df_data['Name']}")
return "R"

View File

@ -67,7 +67,7 @@ START_DATE = 20050403 # YYYYMMDD format - 2005 Opening Day
# END_DATE = 20050531 # YYYYMMDD format - May PotM
END_DATE = 20050731 # End of July 2005
POST_DATA = True
LAST_WEEK_RATIO = 0.0 if PLAYER_DESCRIPTION == "Live" else 0.0
LAST_WEEK_RATIO = 0.0
LAST_TWOWEEKS_RATIO = 0.0
LAST_MONTH_RATIO = 0.0

View File

@ -1,10 +1,4 @@
from creation_helpers import pd_positions_df, mround, sanitize_chance_output
def test_positions_df():
cardset_19_pos = pd_positions_df(19)
assert True == True
from creation_helpers import mround, sanitize_chance_output
def test_mround():