Commit 56104e70 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Do the parsing of the todo strings in the TodoList.

parent 9bc283b1
......@@ -2,8 +2,6 @@
This module deals with todo.txt files.
"""
import TodoBase
class TodoFile(object):
"""
This class represents a todo.txt file, which can be read from or written
......@@ -16,14 +14,11 @@ class TodoFile(object):
def read(self):
""" Reads the todo.txt file and returns a list of todo items. """
todos = []
todofile = open(self.path, 'r')
for line in todofile:
todos.append(TodoBase.TodoBase(line))
todos = todofile.readlines()
todofile.close()
return todos
def write(self, p_todos):
......@@ -34,6 +29,6 @@ class TodoFile(object):
todofile = open(self.path, 'w')
for todo in p_todos:
todofile.write(todo.src + "\n")
todofile.write("%s" % todo)
todofile.close()
......@@ -2,6 +2,8 @@
A list of todo items.
"""
import Todo
class TodoList(object):
"""
Provides operations for a todo list, such as adding items, removing them,
......@@ -12,12 +14,13 @@ class TodoList(object):
"""
_todos = []
def __init__(self, todos):
def __init__(self, p_todostrings):
"""
Should be given a list of Todo objects (already read and parsed from
file or standard input.
Should be given a list of strings, each element a single todo string.
The string will be parsed.
"""
self._todos = todos
for string in p_todostrings:
self._todos.append(Todo.Todo(string))
def todo(self, p_number):
"""
......@@ -33,10 +36,6 @@ class TodoList(object):
return result
def todos(self):
""" Returns the list of all todos. """
return self._todos
def add(self, p_item):
"""
Given a Todo(Base) item, add it to the end of the list.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment