Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
topydo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
topydo
Commits
947ec5ae
Commit
947ec5ae
authored
Nov 22, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add first support for todo items with a base36 ID.
parent
43122a1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
topydo/lib/TodoList.py
topydo/lib/TodoList.py
+3
-0
topydo/lib/TodoListBase.py
topydo/lib/TodoListBase.py
+14
-0
No files found.
topydo/lib/TodoList.py
View file @
947ec5ae
...
...
@@ -44,6 +44,8 @@ class TodoList(TodoListBase.TodoListBase):
self
.
_todos
=
[]
self
.
_tododict
=
{}
# hash(todo) to todo lookup
self
.
_depgraph
=
Graph
.
DirectedGraph
()
self
.
_todo_id_map
=
{}
self
.
_id_todo_map
=
{}
self
.
add_list
(
p_todostrings
)
self
.
dirty
=
False
...
...
@@ -87,6 +89,7 @@ class TodoList(TodoListBase.TodoListBase):
self
.
_tododict
[
hash
(
todo
)]
=
todo
self
.
_maintain_dep_graph
(
todo
)
self
.
_update_todo_ids
()
self
.
_update_parent_cache
()
self
.
dirty
=
True
...
...
topydo/lib/TodoListBase.py
View file @
947ec5ae
...
...
@@ -22,6 +22,7 @@ from datetime import date
import
re
import
Filter
from
HashListValues
import
hash_list_values
from
PrettyPrinter
import
pretty_print_list
import
Todo
import
View
...
...
@@ -44,6 +45,8 @@ class TodoListBase(object):
The string will be parsed.
"""
self
.
_todos
=
[]
self
.
_todo_id_map
=
{}
self
.
_id_todo_map
=
{}
self
.
add_list
(
p_todostrings
)
self
.
dirty
=
False
...
...
@@ -100,6 +103,7 @@ class TodoListBase(object):
for todo in p_todos:
self._todos.append(todo)
self._update_todo_ids()
self.dirty = True
def delete(self, p_todo):
...
...
@@ -187,6 +191,16 @@ class TodoListBase(object):
"""
return lambda p_todo_str, p_todo: "%3d %s" % (self.number(p_todo), p_todo_str)
def _update_todo_ids(self):
# the idea is to have a hash that is independent of the position of the
# todo. Use the text (without tags) of the todo to keep the id as stable
# as possible (not influenced by priorities or due dates, etc.)
uids = hash_list_values(self._todos, lambda t: hash(t.text()))
for (todo, uid) in uids:
self._todo_id_map[todo] = uid
self._id_todo_map[uid] = todo
def __str__(self):
return '
\
n
'.join(pretty_print_list(self._todos))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment