Commit a182079b authored by Bram Schoenmakers's avatar Bram Schoenmakers

Eliminate number attribute stored in each todo.

Now, the todolist is the owner of the numbers.
parent 57cdffa2
...@@ -16,7 +16,7 @@ class Todo(TodoBase.TodoBase): ...@@ -16,7 +16,7 @@ class Todo(TodoBase.TodoBase):
def __init__(self, p_str): def __init__(self, p_str):
TodoBase.TodoBase.__init__(self, p_str) TodoBase.TodoBase.__init__(self, p_str)
self.attributes = { 'number': -1} self.attributes = {}
def get_date(self, p_tag): def get_date(self, p_tag):
""" Given a date tag, return a date object. """ """ Given a date tag, return a date object. """
......
...@@ -24,6 +24,7 @@ class TodoList(object): ...@@ -24,6 +24,7 @@ class TodoList(object):
The string will be parsed. The string will be parsed.
""" """
self._todos = [] self._todos = []
self._numbers = {} # maintains todo -> number mapping
self._depgraph = Graph.DirectedGraph() self._depgraph = Graph.DirectedGraph()
for string in p_todostrings: for string in p_todostrings:
...@@ -104,7 +105,7 @@ class TodoList(object): ...@@ -104,7 +105,7 @@ class TodoList(object):
Then there will be an edge 1 --> 2 with ID 4. Then there will be an edge 1 --> 2 with ID 4.
""" """
p_todo.attributes['number'] = len(self._todos) + 1 self._numbers[p_todo] = len(self._todos) + 1
self._todos.append(p_todo) self._todos.append(p_todo)
self._maintain_dep_graph(p_todo) self._maintain_dep_graph(p_todo)
...@@ -291,7 +292,7 @@ class TodoList(object): ...@@ -291,7 +292,7 @@ class TodoList(object):
self.dirty = True self.dirty = True
def number(self, p_todo): def number(self, p_todo):
return p_todo.attributes['number'] # TODO: do the lookup return self._numbers[p_todo]
def pp_number(self): def pp_number(self):
""" """
......
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