-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow.py
32 lines (29 loc) · 1013 Bytes
/
show.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from rich import print
from rich.panel import Panel
from datetime import datetime,timedelta
class Show:
@staticmethod
def _error_handler(func):
def handler(*args,**kwargs):
try:
return func(*args,**kwargs)
except Exception as e:
raise e
return handler
@_error_handler
def calculate_end_time(self,entry):
start = datetime.strptime(entry[1],"%H:%M")
end = start + timedelta(minutes=int(entry[2]))
return end
@_error_handler
def show(self,data):
data = sorted(data,key=lambda x:x[1])
for index,entry in enumerate(data):
end_time = self.calculate_end_time(entry)
print(
Panel(
f"[bold green]{entry[0]}",
title=f"[italic blue]{entry[1]} | Task Number : {index}",
subtitle=f"[italic red]{end_time.hour}:{end_time.minute} | {entry[2]} Minutes"
),"\n"
)