Files
tt/lib/ui.py

17 lines
594 B
Python
Raw Normal View History

2024-06-13 10:38:43 +02:00
from .TimeSlot import TimeSlot
def convert_to_table(time_slot_list: list[TimeSlot]):
widths = [20, 26, 26]
r_str = f"+{'-'*(widths[0]+2)}+{'-'*(widths[1]+2)}+{'-'*(widths[2]+2)}+\n"
r_str += f"| {'Name':<20} | {'Startzeitpunkt':<26} | {'Endzeitpunkt':<26} |\n"
r_str += f"+{'-'*(widths[0]+2)}+{'-'*(widths[1]+2)}+{'-'*(widths[2]+2)}+\n"
for time_slot in time_slot_list:
r_str += f"| {time_slot.name:<20} | {str(time_slot.start):<26} | {str(time_slot.end):<26} |\n"
r_str += f"+{'-'*(widths[0]+2)}+{'-'*(widths[1]+2)}+{'-'*(widths[2]+2)}+"
return r_str