Add capacity for writing todos to todomanager
This commit is contained in:
@@ -14,7 +14,7 @@ class TodoManager:
|
|||||||
return path.exists(self.filename)
|
return path.exists(self.filename)
|
||||||
|
|
||||||
def open_todo_file(self):
|
def open_todo_file(self):
|
||||||
self.file = open(self.filename, "a")
|
self.file = open(self.filename, "w")
|
||||||
return self.file
|
return self.file
|
||||||
|
|
||||||
def read_todos(self) -> list[Todo]:
|
def read_todos(self) -> list[Todo]:
|
||||||
@@ -27,4 +27,14 @@ class TodoManager:
|
|||||||
return todos
|
return todos
|
||||||
|
|
||||||
def close_todo_file(self):
|
def close_todo_file(self):
|
||||||
self.file.close()
|
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