diff options
Diffstat (limited to 'nba/playoff.py')
| -rw-r--r-- | nba/playoff.py | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/nba/playoff.py b/nba/playoff.py index eb3b12b..42c3b0b 100644 --- a/nba/playoff.py +++ b/nba/playoff.py @@ -21,6 +21,7 @@ def fetch_playoff_picture() -> dict: def _clinch_status(row: list, idx: dict) -> str: """Return a color-coded status string from clinch/elimination columns.""" + def val(col): return row[idx[col]] if col in idx else None @@ -54,19 +55,31 @@ def _build_conference_table(result_sets: list, name: str) -> str: losses = get(row, "LOSSES") pct = get(row, "PCT") pct_str = f"{float(pct):.3f}" if pct not in ("", None) else "" - table_data.append([ - get(row, "RANK"), - get(row, "TEAM"), - f"{wins}-{losses}", - pct_str, - get(row, "GB"), - get(row, "HOME"), - get(row, "AWAY"), - get(row, "CONF"), - _clinch_status(row, idx), - ]) - - display_headers = ["#", "Team", "W-L", "PCT", "GB", "HOME", "AWAY", "CONF", "Status"] + table_data.append( + [ + get(row, "RANK"), + get(row, "TEAM"), + f"{wins}-{losses}", + pct_str, + get(row, "GB"), + get(row, "HOME"), + get(row, "AWAY"), + get(row, "CONF"), + _clinch_status(row, idx), + ] + ) + + display_headers = [ + "#", + "Team", + "W-L", + "PCT", + "GB", + "HOME", + "AWAY", + "CONF", + "Status", + ] conf_label = "Eastern" if "East" in name else "Western" title = f"{BOLD}{conf_label} Conference Playoff Picture:{END}" return title + "\n" + tabulate(table_data, headers=display_headers, tablefmt="grid") |
