baseball/output.py

26 lines
714 B
Python

from rich import box
from rich.table import Table
def output_game(game):
table = Table(width=50, box=box.SQUARE)
table.add_column(game.status.title, width=32)
table.add_column("R", width=3, justify="right")
table.add_column("H", width=3, justify="right")
table.add_column("E", width=3, justify="right")
home_team = game.home_team
away_team = game.away_team
table.add_row(home_team.name,
str(home_team.runs),
str(home_team.hits),
str(home_team.errors))
table.add_row(away_team.name,
str(away_team.runs),
str(away_team.hits),
str(away_team.errors))
return table