Add capacity for writing todos to todomanager
This commit is contained in:
@@ -14,7 +14,7 @@ class TodoManager:
|
||||
return path.exists(self.filename)
|
||||
|
||||
def open_todo_file(self):
|
||||
self.file = open(self.filename, "a")
|
||||
self.file = open(self.filename, "w")
|
||||
return self.file
|
||||
|
||||
def read_todos(self) -> list[Todo]:
|
||||
@@ -28,3 +28,13 @@ class TodoManager:
|
||||
|
||||
def close_todo_file(self):
|
||||
self.file.close()
|
||||
|
||||
def get_todos(self) -> list[Todo]:
|
||||
if not self.does_todo_file_exist():
|
||||
return []
|
||||
|
||||
return self.read_todos()
|
||||
|
||||
def write_todos(self, todos: list[Todo]):
|
||||
for t in todos:
|
||||
self.file.write(str(t) + "\n")
|
||||
Reference in New Issue
Block a user