def get_task_list(name): filename = "task_list_" + name.lower() + ".csv" tasks = TaskList(name) with open(filename, newline="") as file: reader = csv.reader(file) for row in reader: # convert row to Task object task = Task(row[0]) if row[1] == 'True': task.completed = True tasks.addTask(task) return tasks
def get_task_list(name): filename = name.lower() + ".csv" tasks = TaskList(name) with open( filename, newline="", ) as file: reader = csv.reader(file) # next(reader, None) #skip the headers for row in reader: # convert row into tasks task = Task(row[0], row[1]) tasks.addTask(task) return tasks
def main(): task_list_names = get_task_list_names() name = task_list_names[0] tasks = TaskList(name) task1 = Task("Buy toothbrush") tasks.addTask(task1) task2 = Task("Do homework") task2.completed = True tasks.addTask(task2) write_task_list(name, tasks) tasks = get_task_list(name) print(tasks)
from objects import Task, TaskList task1 = Task("Pay bills") task2 = Task("Get groceries") task3 = Task("Make dentist appointment") tasks = TaskList("Personal") tasks.addTask(task1) tasks.addTask(task2) tasks.addTask(task3) task = tasks.getTask(1) task.completed = True print(tasks) tasks.removeTask(task) print(tasks)