taskprinter.py (1871B)
1 class TaskPrinter: 2 COMPLETED_M = "[x]" 3 DELETED_M = "[d]" 4 EXPIRED_M = "[e]" 5 ACTIVE_M = "[ ]" 6 7 @classmethod 8 def mark_choser(cls, task) -> str: 9 """Returns pretty thing:3""" 10 match task.status.value: 11 case "active": 12 return cls.ACTIVE_M 13 case "deleted": 14 return cls.DELETED_M 15 case "expired": 16 return cls.EXPIRED_M 17 case "completed": 18 return cls.COMPLETED_M 19 case _: 20 return " " 21 22 @classmethod 23 def print_tasks_all(cls, tasks): 24 for task in tasks: 25 cls.task_out(task, 1, 0, 1, 1, 1) 26 27 @classmethod 28 def print_tasks(cls, tasks): 29 for task in tasks: 30 if task.status.value == "deleted": 31 continue 32 33 cls.task_out(task, 1, 0, 1, 1, 1) 34 35 @classmethod 36 def print_id_all(cls, tasks): 37 for task in tasks: 38 cls.task_out(task, 1, 1, 1, 1, 1) 39 40 @classmethod 41 def print_id(cls, tasks): 42 for task in tasks: 43 if task.status.value == "deleted": 44 continue 45 46 cls.task_out(task, 1, 1, 1, 1, 1) 47 48 @classmethod 49 def print_active(cls, tasks): 50 for task in tasks: 51 if task.status.value != "active": 52 continue 53 54 cls.task_out(task, 1, 0, 1, 1, 1) 55 56 @classmethod 57 def task_out(cls, task, sta=0, id=0, nam=0, des=0, exp=0): 58 """Task output template, out tasks ONLY via this function!""" 59 print( 60 f"{cls.mark_choser(task)}" if sta else "", 61 f'| "{task.creation_date}" |' if id else "", 62 f"{task.name}" if nam else "", 63 f"| {task.description} " if task.description and des else "", 64 f"| {task.expiration_date}" if task.expiration_date and exp else "", 65 )